java编程 继承关系

2022-08-14 汽车 71阅读

class Transport {

public Transport() {
}
}

class Bus extends Transport {

private String busName;

public Bus(String busName) {
this.busName = busName;
}
}

class Train extends Transport {

private String trainName;
private double trainSpeed;

public Train(String trainName, double trainSpeed) {
this.trainName = trainName;
this.trainSpeed = trainSpeed;
}
}

class Airplane extends Transport {

private String airplaneName;
private double airplaneSpeed;
private String Voyage;

public Airplane(String airplaneName, double airplaneSpeed, String Voyage) {
this.airplaneName = airplaneName;
this.airplaneSpeed = airplaneSpeed;
this.Voyage = Voyage;
}
}
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com