我的作业,挂出来大家一起讨论学习
package com.imooc;
public class Transport { //父类
String vehicle;//运输工具
String condition;//运输环境
int seatNum;//座位数
public void Fro() {
}
public void setAll(String vehicle,String condition,int seatNum) {
this.vehicle=vehicle;
this.condition=condition;
this.seatNum=seatNum;
}
public void getAll() {
System.out.println(vehicle+"在"+condition+"上运输,载客数为"+seatNum);
}
}
package com.imooc;
public class TransportTest extends Transport {// 子类
public void Fro() {
System.out.println("********每种交通工具都有它的运输工具、运输环境和载客数**************");
}
public static void main(String[] args) {
Transport t1 = new TransportTest();
Transport t2 = new TransportTest();
Transport t3 = new TransportTest();
t1.Fro();
t1.setAll("大巴", "马路", 40);
t2.setAll("船", "水", 200);
t3.setAll("飞机", "天", 500);
t1.getAll();
t2.getAll();
t3.getAll();
}
}