62,623
社区成员
发帖
与我相关
我的任务
分享class aaa {
private String name;
private String location;
public aaa(String name, String address) {
this.name = name;
this.location = address;
}
public String toString() {
return name + "在" + location;
}
public String getName(){
return name;
}
public String getLocation(){
return location;
}
}
class bbb extends aaa {
private int population;
public bbb(String name, String location) {
super(name, location);
population = 2;
}
public bbb(String name, String location, int population) {
super(name, location);
this.population = population + 10000;
}
public void setPopulation(int population) {
this.population = population;
}
public int getPopulation() {
return population;
}
public String toString()
{
return this.getName() + "in" + this.getLocation() + ":人口数量" + population + "\n";
}
}
class useX1 {
public static void main(String args[]) {
bbb b1 = new bbb("aaa", "bbb");
System.out.println(b1);
bbb b2 = new bbb("ccc", "ddd", 31);
System.out.print(b2);
}
}
public String toString() {
return super.toString()+":人口数量"+population+"\n";
}
class bbb {
private int population;
private String name;
private String location;
public bbb(String name, String location) {
// super(name, location);
this.name = name;
this.location = location;
population = 2;
}
public bbb(String name, String location, int population) {
// super(name, location);
this.name = name;
this.location = location;
this.population = population + 10000;
}
public void setPopulation(int population) {
this.population = population;
}
public int getPopulation() {
return population;
}
public String toString()
{
return name + "in" + location + ":人口数量" + population + "\n";
}
}