public class Pets {
private String color; //颜色
private int age; //年龄
private String sex; //性别
private String kind;
private double inPrice; //进货价格
private double outPrice; //销售价格
private double profit; //盈利
public Pets(String color, int age, String sex) {
this.color = color;
this.age = age;
this.sex = sex;
}
public Pets() {
}
public String getKind() {
return kind;
}
public void setKind(String kind) {
this.kind = kind;
}
public double getProfit() {
return profit;
}
public void setProfit(double profit) {
this.profit = profit;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public double getInPrice() {
return inPrice;
}
public void setInPrice(double inPrice) {
this.inPrice = inPrice;
}
public double getOutPrice() {
return outPrice;
}
public void setOutPrice(double outPrice) {
this.outPrice = outPrice;
}
}
就是定义了一个Pets类,颜色、年龄这些都是类的属性,下面的就是构造函数和设置属性的方法和获取属性的方法
参见下图:
你得说哪不懂啊?