哪位大神可以帮我看一下这样写可以吗
//父类
public class Vehicle {
public int carryNum;//可载人数
public String move;//运行方式
public String models;//工具类型
public void method(){
System.out.println("交通工具中:"+models+"在"+move+"可以载客"+carryNum+"人");
}
}
//公交车子类
public class Bus extends Vehicle {
public void method(){
this.carryNum=40;
this.move="陆地";
this.models="公交车";
System.out.println("交通工具中:"+models+"在"+move+"可以载客"+carryNum+"人");
}
}
//飞机子类
public class Plane extends Vehicle{
public void method(){
this.carryNum=200;
this.move="天空";
this.models="飞机";
System.out.println("交通工具中:"+models+"在"+move+"可以载客"+carryNum+"人");
}
}
//轮船子类
public class Ship extends Vehicle {
public void method(){
this.carryNum=2000;
this.move="海洋";
this.models="轮船";
System.out.println("交通工具中:"+models+"在"+move+"可以载客"+carryNum+"人");
}
}
//测试
public class Test {
public static void main(String[] args) {
Vehicle d = new Vehicle();
Vehicle d1= new Bus();
Vehicle d2= new Ship();
Vehicle d3= new Plane();
d1.method();
d2.method();
d3.method();
}
}