课后作业是我做的这意思不
package com.练习;
//父类Vehicle
public class Vehicle {
public int man;//载人
public String way;//在哪跑(陆地,水上,空中)
public void manned() {
System.out.println("交通工具在"+way+"能够运输 "+man+"个客人");
}
}
//子类Bus
public class Bus extends Vehicle {
int man = 50;
String way = "陆地";
public void manned() {
System.out.println("公共汽车在"+way+"能够运输 "+man+"个客人");
}
}
//子类Steamer
public class Steamer extends Vehicle {
int man = 100;
String way = "海上";
public void manned() {
System.out.println("轮船在"+way+"能够运输 "+man+"个客人");
}
}
//子类Plane
public class Plane extends Vehicle {
int man = 500;
String way = "空中";
public void manned() {
System.out.println("飞机在"+way+"能够运输 "+man+"个客人");
}
}
public class Initial {
public static void main(String[] args) {
// TODO 自动生成的方法存根
Vehicle bus = new Bus();
Vehicle stea = new Steamer();
Vehicle plane = new Plane();
bus.manned();
stea.manned();
plane.manned();
}
}
//最后结果
公共汽车在陆地能够运输 50个客人
轮船在海上能够运输 100个客人
飞机在空中能够运输 500个客人