first commit
This commit is contained in:
24
CS1322/t3/Dog.java
Normal file
24
CS1322/t3/Dog.java
Normal file
@@ -0,0 +1,24 @@
|
||||
public class Dog extends Animal{
|
||||
|
||||
public Dog(String name){
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Dog(){
|
||||
}
|
||||
public void speak(){
|
||||
|
||||
System.out.println("Woof. My name is "+this.name);
|
||||
}
|
||||
|
||||
public void play(){
|
||||
|
||||
System.out.println("I am playing.");
|
||||
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
|
||||
return "I am a dog named " + this.name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user