请问我这个练习题理解行吗
父类
飞机
主函数
轮船
客车
父类
飞机
主函数
轮船
客车
2018-12-30
package com.nuist.transport;
public class PractiseTransport {
private String ways;
private String personNum;
private String conveyance;
public void PracticeTransportation(){
}
public void print(){
System.out.println("使用"+this.conveyance+"在"+this.ways+"运输"+this.personNum+"人");
}
public String getWays() {
return ways;
}
public void setWays(String ways) {
this.ways = ways;
}
public String getPersonNum() {
return personNum;
}
public void setPersonNum(String personNum) {
this.personNum = personNum;
}
public String getConveyance() {
return conveyance;
}
public void setConveyance(String conveyance) {
this.conveyance = conveyance;
}
}
package com.nuist.transport;
public class PractisePlane extends PractiseTransport{
public PractisePlane(){
this.setConveyance("飞机");
this.setPersonNum("200");
this.setWays("天空");
}
}
package com.nuist.transport;
public class PractiseShip extends PractiseTransport {
public PractiseShip(){
this.setConveyance("轮船");
this.setPersonNum("150");
this.setWays("海洋");
}
}
package com.nuist.transport;
public class PractiseBus extends PractiseTransport {
public PractiseBus(){
this.setConveyance("公共汽车");
this.setPersonNum("40");
this.setWays("公路");
}
}
package com.nuist.transport;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
PractiseTransport a=new PractisePlane();
PractiseTransport b=new PractiseShip();
PractiseTransport c=new PractiseBus();
a.print();b.print();c.print();
}
}
刚刚写的,你可以参考下,你的代码小错误很多,要不把前面的视频再看看??
举报