package com.答答租车系统;
import java.util.*;
public class Car { //父类
public int id;
public String name;
public String price;
public Car(int id,String name,String price) {
this.id=id;
this.name=name;
this.price=price;
System.out.print(id+"\t"+name+"\t"+price+"\t");
}
}
public class Huocar extends Car {// 子类货车
public String zaihuo;
public Huocar(int id,String name,String price,String zaihuo) {
super(id,name,price);
this.zaihuo=zaihuo;
System.out.println(zaihuo+"\t");
}
}
public class Kecar extends Car {//子类客车
public String zairen;
public Kecar(int id,String name,String price,String zairen) {
super(id,name,price);
this.zairen=zairen;
System.out.println(zairen+"\t");
}
}
public class Picar extends Car {//子类皮卡
public String zaihuo;
public String zairen;
public Picar(int id,String name,String price,String zairen, String zaihuo ) {
super(id,name,price);
this.zaihuo=zaihuo;
this.zairen=zairen;
System.out.print(zairen+"\t");
System.out.println(zaihuo+"\t");
}
}
public class Main {
public static void main(String[] args) {
System.out.println("欢迎使用答答租车系统");
System.out.println("您是否需要租车 : 1是 0否");
Scanner input=new Scanner(System.in);
int judge1=input.nextInt();//获取输入值
if(judge1==1)
{
System.out.println("序号\t车辆名称\t 租车价格\t 容量\t");
Car car[]= {new Kecar(1,"奥迪A4","500元/天","载人:4人"),
new Kecar(2,"马自达6","400元/天","载人:4人"),
new Picar(3,"皮卡雪","450元/天","载人:4人","载重:2吨"),
new Kecar(4,"金龙","800元/天","载人:20人"),
new Huocar(5,"松花江","400元/天","载重:4吨"),
new Huocar(6,"依维柯","1000元/天","载重:20吨")};//构造方法输出信息
/*System.out.println("序号"+"\t"+"车辆名称"+"\t"+"租车价格"+"\t"+" 容量"+"\t");
Car car1=new Kecar(1,"奥迪A4","500元/天","载人:4人");
Car car2=new Kecar(2,"马自达6","400元/天","载人:4人");
Car car3=new Picar(3,"皮卡雪","450元/天","载人:4人","载重:2吨");
Car car4=new Kecar(4,"金龙","800元/天","载人:20人");
Car car5=new Huocar(5,"松花江","400元/天","载重:4吨");
Car car6=new Huocar(6,"依维柯","1000元/天","载重:20吨");*/
}else
{
System.out.println("如有需要欢迎您的使用,再见");
System.exit(0);
}
System.out.println("请输入您要租汽车的数量");
int sum=input.nextInt();
int s;
String zr[]=new String[sum];
int weight=0;//计算总载重
int peosum=0;//计算总人数
int monsum=0;//计算总钱数
for(int i=0;i<sum;i++) {
System.out.println("请输入第"+(i+1)+"辆租车的序号");
s=input.nextInt(); //保存各辆车
switch (s) {
case 1: peosum=peosum+4;monsum=monsum+500;zr[i]="奥迪A4";continue;
case 2: peosum=peosum+4;monsum=monsum+400;zr[i]="马自达6";continue;
case 3: peosum=peosum+4;monsum=monsum+450;zr[i]="皮卡雪6";weight=weight+2;continue;
case 4: peosum=peosum+20;monsum=monsum+800;zr[i]="金龙";continue;
case 5: monsum=monsum+400;weight=weight+4;zr[i]="松花江";continue;
case 6: monsum=monsum+1000;weight=weight+20;zr[i]="依维柯";continue;
}
}
System.out.println("请输入您要租车的天数");
int daysum=input.nextInt();
int monsums=daysum*monsum;//总金额
System.out.println("您的账单");
System.out.println("****可载人的车有"+"\n"+" 共载人 :"+peosum);
System.out.println("****可载货的车有"+"\n"+" 共载货 :"+weight+"吨");
System.out.println("****租车总价格 : " + monsums);
System.out.println("欢迎再次使用");
}
}