package cn.hello.test5;
/**
* 客车类,继承汽车类。
* @author 北大青鸟
*/
public final class Bus extends MotoVehicle {
private int seatCount;// 座位数
public Bus() {
}
public Bus(String no, String brand, int seatCount) {
super(no, brand);
this.seatCount = seatCount;
}
public int getSeatCount() {
return seatCount;
}
public void setSeatCount(int seatCount) {
this.seatCount = seatCount;
}
/**
* 计算客车租赁价
*/
public int calRent(int days) {
if (seatCount <= 16) {
return days * 800;
} else {
return days * 1500;
}
}
}
package cn.hello.test5;
/**
* 轿车类,继承汽车类。
* @author 北大青鸟
*/
public final class Car extends MotoVehicle {
private String type;// 汽车型号
public Car() {
}
public Car(String no, String brand, String type) {
super(no, brand);
this.type = type;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
/**
* 计算轿车租赁价
*/
public int calRent(int days) {
if ("1".equals(ty
JavaOOP 继承实现汽车租赁计算价格
最新推荐文章于 2022-11-04 20:54:37 发布