package qwr;
import java.util.Scanner;
/**
* Created by Administrator on 2016/12/2.
*/
public class Initial {
static int is = 0;
public static void main(String[] args) {
Initial it = new Initial();
System.out.println("請問您是否需要租車纲堵?");
System.out.println("輸入:1進(jìn)入挑選 輸入0:退出");
do {
Scanner sc = new Scanner(System.in);
int isof = sc.nextInt();
if (isof == 0) {
System.out.println("歡迎您下次光臨!");
break;
} else if (isof == 1) {
System.out.println("請?zhí)暨x你想選擇的車輛割卖!");
is = isof;
it.test();
break;
} else {
System.out.println("輸入有誤窿克,請重新輸入兵怯!");
continue;
}
}while (true);
}
public void test() {
Didi[] carsForRent = {
new PassengerCar("奧迪A4", 500, 4),
new PassengerCar("馬自達(dá)6", 500, 4),
new PickUp("皮卡雪6", 450, 4, 2),
new PassengerCar("金龍", 800, 20),
new CurrentCar("松花江", 400, 4),
new CurrentCar("依維柯", 1000, 20)};
int i = 1;
if (is == 1) {
for (Didi currentCar : carsForRent) {
if (currentCar instanceof PassengerCar) {
System.out.println("" + i + "\t" + currentCar.getName() + "\t" + currentCar.getRentm() + "元/天" + "\t" + "載人:" + currentCar.getTake() + "人");
i++;
} else if (currentCar instanceof PickUp) {
System.out.println("" + i + "\t" + currentCar.getName() + "\t" + currentCar.getRentm() + "元/天" + "\t" + "載人:" + currentCar.getTake() + "人" + "載貨:" + currentCar.getTon() + "噸");
i++;
} else {
System.out.println("" + i + "\t" + currentCar.getName() + "\t" + currentCar.getRentm() + "元/天" + "\t" + "載貨:" + currentCar.getTon() + "噸");
i++;
}
}
}
double money = 0;
do {
System.out.println("請輸入你想要租車的序號(選購?fù)瓿烧堓斎?):");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if (n == 0) {
System.out.println("歡迎您下次光臨!");
System.out.println("**租車總價格:" + money + "元");
System.out.println("**可載人的車有:");
int sumper = 0;
for (int x = 0; x < 6; x++) {
if (carsForRent[x].getRentsum() > 0 && carsForRent[x].getTake() > 0) {
System.out.print(carsForRent[x].getName() + "x" + carsForRent[x].getRentsum());
sumper = sumper + carsForRent[x].getRentsum() * carsForRent[x].getTake();
}}
if (sumper > 0) {
System.out.println("\t" + "可載人: " + sumper + "人");
}
else{
System.out.println("無車可載人!");
}
int ton = 0;
System.out.println("**可載貨的車有:");
for (int x = 0; x < 6; x++) {
if (carsForRent[x].getRentsum() > 0 && carsForRent[x].getTon() > 0) {
System.out.print(carsForRent[x].getName() + "x" + carsForRent[x].getRentsum());
ton = ton + carsForRent[x].getRentsum() * carsForRent[x].getTon();
}
}
if (ton > 0) {
System.out.println("\t" + "可載貨:" + ton + "噸");
} else {
System.out.println("無車可載貨撞反!");
}
break;}
else if (n == 1 || n == 2 || n == 3 || n == 4 || n == 5 || n == 6) {
switch (n) {
case 1:
System.out.println("請輸入你想要租車的數(shù)量:");
int sum = sc.nextInt();
carsForRent[n - 1].setRentsum(sum);
double m1 = 500 * sum;
System.out.println("請輸入你想要租用的天數(shù):");
money = money + m1 * sc.nextInt();
break;
case 2:
System.out.println("請輸入你想要租車的數(shù)量:");
sum = sc.nextInt();
carsForRent[n - 1].setRentsum(sum);
m1 = 400 * sum;
System.out.println("請輸入你想要租用的天數(shù):");
money = money + m1 * sc.nextInt();
break;
case 3:
System.out.println("請輸入你想要租車的數(shù)量:");
sum = sc.nextInt();
carsForRent[n - 1].setRentsum(sum);
m1 = 450 * sum;
System.out.println("請輸入你想要租用的天數(shù):");
money = money + m1 * sc.nextInt();
break;
case 4:
System.out.println("請輸入你想要租車的數(shù)量:");
sum = sc.nextInt();
carsForRent[n - 1].setRentsum(sum);
m1 = 800 * sum;
System.out.println("請輸入你想要租用的天數(shù):");
money = money + m1 * sc.nextInt();
break;
case 5:
System.out.println("請輸入你想要租車的數(shù)量:");
sum = sc.nextInt();
carsForRent[n - 1].setRentsum(sum);
m1 = 400 * sum;
System.out.println("請輸入你想要租用的天數(shù):");
money = money + m1 * sc.nextInt();
break;
case 6:
System.out.println("請輸入你想要租車的數(shù)量:");
sum = sc.nextInt();
carsForRent[n - 1].setRentsum(sum);
m1 = 1000 * sum;
System.out.println("請輸入你想要租用的天數(shù):");
money = money + m1 * sc.nextInt();
break;}
}
else{
System.out.println("輸入有誤鸦列,請重新輸入租冠!");
continue;}
}while (true) ;
}
}