petshop2.0java宠物商店-源代码
PetShop2.0
(应用继承extends)
Pet.java
public class Pet{
private String name;
private String color;
404页面网站源码
private int age;
public String getName() {
return name;
}
public void setName(String name) { this.name = name;
}
public String getColor() {
return color;
}
public void setColor(String color) { lor = color;
}
public int getAge() {
public Dog(String name, String color, int age, String type) {
super(name, color, age);
}
public String getType() {
return type;
}
public void setType(String type) {
}
public void eat(){
System.out.println("I like eating bone!");
}
}
Cat.java
public class Cat extends Pet {
private double weight;
public Cat(String name, String color, int age, double weight) {
super(name, color, age);
this.weight = weight;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。