package zjm;
import java.util.*;
public class Test {
public static void main(String[] args) {
// TODO 自动生成的方法存根
Car[] car={new passageCar("奥迪A4",500,4,0),new passageCar("马自达6",400,4,0),new pickupCar("皮卡雪6",450,4,2),
new passageCar("金龙",800,20,0),new objectCar("松花江",400,0,4),new objectCar("依维柯",1000,0,20)};
int totalPrice=0;
int totalPer=0;
int totalObj=0;
//StringBuffer totalName=new StringBuffer();
System.out.println("欢迎使用答答租车系统");
System.out.println("请问您是否要租车:1.是 2.否");
Scanner in=new Scanner(System.in);
if(in.nextInt()==1){
System.out.println("您可以租车的类型及其价目表:");
System.out.println("序号\t汽车名称\t租金\t容量");
for(int i=0;i<car.length;i++){
System.out.println((i+1)+"\t"+car[i].toString());
}
System.out.println("您输入您要租汽车的数量:");
int num=in.nextInt();
int []arr=new int[num];
for(int i=0;i<num;i++){
System.out.println("请输入第"+(i+1)+"车的序号");
arr[i]=in.nextInt();
totalPrice+=car[arr[i]-1].getPrice();
totalPer+=car[arr[i]-1].getCarryPer();
totalObj+=car[arr[i]-1].getCarryObj();
}
System.out.println("请输入您要租车的天数:");
int day=in.nextInt();
System.out.println("您的账单:");
System.out.println("可载人的车有:");
for(int i=0;i<num;i++){
if(arr[i]==1||arr[i]==2||arr[i]==3||arr[i]==4){
System.out.print(car[arr[i]-1].getName()+"\t");
}
}
System.out.println("共载"+totalPer+"人");
System.out.print("可载物的车有:");
for(int i=0;i<num;i++){
if(arr[i]==3||arr[i]==5||arr[i]==6){
System.out.print(car[arr[i]-1].getName()+"\t");
}
}
System.out.println("共载"+totalObj+"吨");
System.out.println("租车的总价格为:"+(totalPrice*day));
}
else{
System.out.println("为什么不租车呢?");
}
}
}