请大佬们看看这样行不行,不行的话应该怎么改
。。。。。
。。。。。
2019-07-20
package tran;
public class Bus extends trano{
/**
* @param args
*/
{ mode="陆地行走";
name="汽车";
number= 25;
}
public void were(){
System.out.println(name+"具有"+mode+"的能力,它一次能载"+number+"人");
}
}
package tran;
public class fly extends trano{
/**
* @param args
*/
{ mode="天空飞行";
name="飞机";
number= 50;
}
public void were(){
System.out.println(name+"具有"+mode+"的能力,它一次能载"+number+"人");
}
}
package tran;
public class boat extends trano{
/**
* @param args
*/
{ mode="海上航行";
name="轮船";
number= 400;
}
public void were(){
System.out.println(name+"具有"+mode+"的能力,它一次能载"+number+"人");
}
}
package tran;
public class trano {
public String mode;
public String name;
public int number;
public void were(){
System.out.println(name+"具有"+mode+"的能力,它一次能载"+number+"人");
}
}
package tran;
public class Initail {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
trano a = new Bus();
trano b = new fly();
trano c = new boat();
a.were();
b.were();
c.were();
}
}
举报