package RentCar;public 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 getSeat(){return seatCount;}//计算租金public int calRent(int days){int rent = 0;if(seatCount <= 16){rent = 800 * days;}else{rent = 1500 * days;}return rent;}} ……………………………………………………………………………………………………………package RentCar;public class Car extends MotoVehicle {private String type; // 轿车的型号//构造方法public Car(){}public Car(String no, String brand, String type){super(no,brand);this.type = type;}//设置轿车的型号public void setType(String type){this.type = type;}//返回轿车型号public String getType(){return type;}//实现父类抽象方法,计算租金public int calRent(int days){int rent = 0;if("宝马".equals(getBrand())){rent = days * 500;}else if("丰田".equals(getBrand())){if(type.equals("GL8")){rent = days * 600;}else{rent = days * 300;}}return rent;}}……………………………………………………………………………………………………………package RentCar;public class Customer {private String name;public Customer(){}public Customer(String name){ = name;}public String getName(){return name;}public int calcTotalRent(MotoVehicle[] moto, int days){int rent = 0 ;for(int i = 0 ;i < moto.length; i++){if(moto[i]!=null){rent = rent + moto[i].calRent(days);}}return rent;}}……………………………………………………………………………………………………………package RentCar;public abstract class MotoVehicle {private String no; //车牌号private String brand; //品牌//构造方法public MotoVehicle(){}public MotoVehicle(String no, String brand){this.no = no;this.brand = brand;}//返回机动车辆的牌照public String getNo(){return no;}//返回机动车辆的品牌public String getBrand(){return brand;}//计算租金的抽象方法public abstract int calRent(int days);}……………………………………………………………………………………………………………package RentCar;import java.util.Scanner;public class Test {public static void main(String[] args){Scanner input = new Scanner(System.in);int days = 0; //租赁的天数int motoType ; //汽车大类型String brand ; //汽车品牌String type = null; //汽车具体类型int seat; //座位数String no; //拍照String answer; //是否继续MotoVehicle[] moto = new MotoVehicle[10];Customer customer = new Customer("小明");System.out.println("欢迎来到汽车租赁公司!");System.out.print("请输入要租赁的天数:");days = input.nextInt();do{System.out.print("请输入要租赁的汽车类型(1.轿车 2.客车):");motoType = input.nextInt();int random = (int)(Math.random()*(99999-10000)+10000);switch(motoType){case 1:no = "粤A" + random; //车辆牌照System.out.print("请输入要租赁的汽车品牌(1.宝马 2.丰田):");if(input.nextInt() == 1){brand = "宝马";type = "320i";}else{brand = "丰田";type = "RAV4";}//实例化一个轿车对象,并添加到moto数组中for(int i = 0 ; i < moto.length ;i ++){if(moto[i] == null){moto[i] = new Car(no,brand,type);break;}}break;case 2:no = "粤A" + random;System.out.print("请输入要租赁的汽车品牌(1.黄海 2.金龙):");//根据选择得到汽车品牌if(input.nextInt() ==1){brand = "黄海";}else{brand = "金龙";}System.out.print("请输入客车的座位数:");seat = input.nextInt(); //汽车座位数//实例化一个轿车对象,并添加到moto数组中for(int i = 0 ; i < moto.length ;i ++){if(moto[i] == null){moto[i] = new Bus(no,brand,seat); //实例化一个汽车对象break;}}break;}System.out.print("是否继续租车?(y/n):");answer = input.next();}while(answer.equals("y"));System.out.println("汽车牌号\t汽车品牌");for(int i = 0 ; i < moto.length ;i ++){if(moto[i] != null){if(moto[i] instanceof Car){Car c = (Car)moto[i];System.out.println(c.getNo()+"\t"+c.getBrand());}else{Bus b = (Bus)moto[i];System.out.println(b.getNo()+"\t"+b.getBrand());}}}System.out.println("客户名:"+customer.getName()+",租赁天数:"+days+",总费用:"+customer.calcTotalRent(moto, days));}} ……………………………………………………………………………………………………………package RentCar;public class Truck extends MotoVehicle {private int weight; //吨位public Truck(){}public Truck(String no, String brand,int weight){super(no,brand);this.weight = weight;}public int getWeight(){return weight;}public int calRent(int days){ int rent = 0;rent = weight * 50 * days;return rent;}}。