public class Dog1 {
private String sex;
private String name;
private String color;
private String voice;
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getVoice() {
return voice;
}
public void setVoice(String voice) {
this.voice = voice;
}
public String introduce() {
return sex+"狗"+name+"是"+color+"色的";
}
public String bark() {
return sex+"狗"+name+"正在"+voice+voice+voice+"叫";
}
public Dog1() {}
public Dog1(String sex, String name, String color) {
this.sex = sex;
this.name = name;
this.color = color;
}
public Dog1(String sex, String name, String color, String voice) {
this.sex = sex;
this.name = name;
this.color = color;
this.voice = voice;
}
}
public class DogText {
public static void main(String[] args) {
Dog Dog1=new Dog("母","lili","绿");
String introduce=Dog1.introduce();
System.out.println(introduce);
Dog Dog2=new Dog("公","biubiu","肤色","汪汪叫");
String bark=Dog2.bark();
System.out.println(bark);
}
}