Dog.java
public class Dog extends Pet {
// private String name;
// private int age;
// private String gender;
private String sound;
public Dog(){
// super();
}
// public Dog(String name){
// super(name);
// }
//
// public Dog(int age,String gender){
// super(age,gender);
// }
public Dog(String name, int age, String gender, String sound) {
// super();
// super(name);
// this(age,gender);
super(name,age,gender);
// this.name = name;
// this.age = age;
// this.gender = gender;
this.sound = sound;
}
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getAge() {
// return age;
// }
//
// public void setAge(int age) {
// this.age = age;
// }
//
// public String getGender() {
// return gender;
// }
//
// public void setGender(String gender) {
// this.gender = gender;
// }
public String getSound() {
return sound;
}
public void setSound(String sound) {
this.sound = sound;
}
public void show(){
// System.out.println("name:" +this.name +" age:" +this.age +" gender:" +this.gender +" sount:" +this.sound);
System.out.println("name:" +this.getName() +" age:" +this.getAge() +" gender:" +this.getGender() +" sount:" +this.sound);
}
@Override
public void print(){
System.out.println("Dog print... ...");
// super.print();
}
}
面向对象子类,个人笔记。
最新推荐文章于 2024-11-08 14:58:24 发布