急用谢谢!!!
3个回答
2020-03-25
展开全部
/**
* 动物类
*/
public class Animal {
private double weight;//重量
private String name; //名字
public Animal() {
}
public Animal(double weight, String name) {
this.weight = weight;
this.name = name;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void show() {
System.out.println(getName() + "有" + getWeight() + "千克");
}
}
/**
* 动物园类
*/
public class Zoo {
public static void main(String[] args) {
Animal cat = new Animal(5,"cat");
Animal dog = new Animal(10,"dog");
cat.show();
dog.show();
cat.setName("小花");
dog.setName("小黑");
cat.setWeight(10);
dog.setWeight(20);
cat.show();
dog.show();
}
}
* 动物类
*/
public class Animal {
private double weight;//重量
private String name; //名字
public Animal() {
}
public Animal(double weight, String name) {
this.weight = weight;
this.name = name;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void show() {
System.out.println(getName() + "有" + getWeight() + "千克");
}
}
/**
* 动物园类
*/
public class Zoo {
public static void main(String[] args) {
Animal cat = new Animal(5,"cat");
Animal dog = new Animal(10,"dog");
cat.show();
dog.show();
cat.setName("小花");
dog.setName("小黑");
cat.setWeight(10);
dog.setWeight(20);
cat.show();
dog.show();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
收费给你操作
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询