Cat
public class Cat extends SuperClass{
//name and breed
private String name;
private String breed;
public Cat(String animalName){
super("Cat");
name = animalName;
breed = "Unknown";
}
//animal constructor
public Cat(String animalName,String animalBreed){
super("Cat");
name = animalName;
breed = animalBreed;
}
//convert to String
public String toString(){
return super.toString() + "\n" + name + "is a" + breed + "type of cat.\n";
}
}
No comments:
Post a Comment