父类Car
public abstract class Car {
public String carType;
public int rentPrice;
}
载人接口
public interface IPassengerCapacity {
public int getcarrypassenger();
}
载货接口
public interface IGoodsCapacity {
public int getcarrygoods();
}
载人类
public class passengerCar extends Car implements IPassengerCapacity {
private int carrypassenger;//载客量
//构造方法
passengerCar(String type,int rentprice,int carrypassenger){
this.carType=type;
this.rentPrice=rentprice;
this.carrypassenger=carrypassenger;
}
public int getcarrypassenger() {
// TODO Auto-generated method stub
return carrypassenger;
}
}
卡车类
public class Trunk extends Car implements IGoodsCapacity {
private int carrygoods;
Trunk(String type,int rentprice,int carrygoods){
this.carType=type;
this.rentPrice=rentprice;
this.carrygoods=carrygoods;
}
public int getcarrygoods() {
// TODO Auto-generated method stub
return carrygoods;
}
}
皮卡类
public class PickUp extends Car implements IPassengerCapacity, IGoodsCapacity {
private int carrypassenger;//载客量
p