package com.xiaoyuanling;import java.util.ArrayList;import java.util.HashSet;import java.util.Scanner;import java.util.Set;public class Method {public Passenger[] passenger={new Passenger("1 ","奥迪A4 ","500","4"),new Passenger("2 ","马自达6 ","400","4"),new Passenger("4 ","金龙 ","800","20")};public PickUp[] pickUp={new PickUp("3 ","皮卡雪 ","450","4","2")};public Trunk[] trunk={new Trunk("5 ","松花江 ","400","4"),new Trunk("6 ","依维柯 ","1000","20")};public ArrayList car1;public ArrayList car2;public ArrayList car3;public Set set1;public Set set2;public Set set3;public int[] sum1;public int[] sum2;public int[] sum3;int sumPickUp;int sumTrunk;int sumPrice;public Method(){
car1=new ArrayList<>();
car2=new ArrayList<>();
car3=new ArrayList<>();
set1=new HashSet<>();
set2=new HashSet<>();
set3=new HashSet<>();
sum1=new int[3];
sum2=new int[3];
sum3=new int[4];
}
public void welcome(){
String number1= "1";
String number2= "0";
Scanner scanner=new Scanner(System.in);
System.out.println("欢迎来到嘀嘀打车系统!");
System.out.println("您是否要租车:"+number1+"是"+number2+"否");
int number3=scanner.nextInt();
if(number3==Integer.valueOf(number1)){
System.out.println("您可租车的类型及其价目表:");
System.out.println("序号 "+"汽车名称 "+"租金 "+"容量");
System.out.println(passenger[0].id+"."+" "+passenger[0].name+" "+passenger[0].price+"元/天"+" "+passenger[0].pickUp+"人");
System.out.println(passenger[1].id+"."+" "+passenger[1].name+" "+passenger[1].price+"元/天"+" "+passenger[1].pickUp+"人");
System.out.println(pickUp[0].id+"."+" "+pickUp[0].name+" "+pickUp[0].price+"元/天"+" "+pickUp[0].pickUp+"人"+pickUp[0].capacity+"吨");
System.out.println(passenger[2].id+"."+" "+passenger[2].name+" "+passenger[2].price+"元/天"+" "+passenger[2].pickUp+"人");
System.out.println(trunk[0].id+"."+" "+trunk[0].name+" "+trunk[0].price+"元/天"+" "+trunk[0].capacity+"吨");
System.out.println(trunk[1].id+"."+" "+trunk[1].name+" "+trunk[1].price+"元/天"+" "+trunk[1].capacity+"吨");
}else if(number3==Integer.valueOf(number2)){
System.out.println("欢迎下次光临,再见");
}
}
public void rentCar(){
System.out.println("请输入你要租车的数量:");
Scanner input=new Scanner(System.in);
int rentnumber=input.nextInt();
for(int i=0;i<rentnumber;i++){
System.out.println("请输入第"+(i+1)+"辆车的序号");
String number1=input.next();
if(number1.equals(passenger[0].id)){
car1.add(passenger[0]);
set1.add(passenger[0]);
}else if(number1.equals(passenger[1].id)){
car1.add(passenger[1]);
set1.add(passenger[1]);
}else if(number1.equals(passenger[2].id)){
car1.add(passenger[2]);
set1.add(passenger[2]);
}else if(number1.equals(pickUp[0].id)){
car2.add(pickUp[0]);
set2.add(pickUp[0]);
}else if(number1.equals(trunk[0].id)){
car3.add(trunk[0]);
set3.add(trunk[0]);
}else if(number1.equals(trunk[1].id)){
car3.add(trunk[1]);
set3.add(trunk[1]);
}
}
System.out.println("请输入租车天数:");
String number2=input.next();
System.out.println("您的账单:");
System.out.println("***可载人的车有");
for(Passenger passenger1:set1){
if(passenger1.id.equals(passenger[0].id)){
System.out.print("奥迪A4");
}else if(passenger1.id.equals(passenger[1].id)){
System.out.print("马自达6");
}else if(passenger1.id.equals(passenger[2].id)){
System.out.print("金龙");
}
}
for(PickUp pickUp1:set2){
if(pickUp1.id.equals(pickUp[0].id)){
System.out.print("皮卡雪");
}
}
for(Passenger passenger2:car1){
sum1[0] += Integer.parseInt(passenger2.pickUp);
}
for(PickUp pickUp2:car2){
sum1[1] += Integer.parseInt(pickUp2.pickUp);
}
sum1[2]=sum1[0]+sum1[1];
System.out.println("共载人:" + sum1[2]);
System.out.println("***载货的车有:");
for(PickUp pickUp3:set2){
if(pickUp3.id.equals(pickUp[0].id)){
System.out.print("皮卡雪");
}
}
for(Trunk trunk1:set3){
if(trunk1.id.equals(passenger[1].id)){
System.out.print("松花江");
}else if(trunk1.id.equals(passenger[2].id)){
System.out.print("依维柯");
}
}
for(PickUp pickUp4:car2){
sum2[0] += Integer.parseInt(pickUp4.capacity);
}
for(Trunk trunk3:car3){
sum2[1] += Integer.parseInt(trunk3.capacity);
}
sum2[2]=sum2[0]+sum2[1];
System.out.println("共载货:"+sum2[2]);
System.out.println("***租车总价格:");
for(Passenger passenger3:set1){
sumPrice += ((Integer.parseInt(passenger3.price))*Integer.parseInt(number2));
sum3[0]=sumPrice;
}
for(PickUp pickUp4:set2){
sumPrice += ((Integer.parseInt(pickUp4.price))*Integer.parseInt(number2));
sum3[1]=sumPrice;
}
for(Trunk trunk4:set3){
sumPrice += ((Integer.parseInt(trunk4.price))*Integer.parseInt(number2));
sum3[2]=sumPrice;
}
sum3[3]=sum3[0]+sum3[1]+sum3[2];
System.out.print(sum3[3]);
}}
添加回答
举报
0/150
提交
取消