package DDsystem;
import java.util.Set;
public class Car {
private String carName;
private String carId;
private int price;
private int busload;
public Car(String carName,String carId ,int price,int busload) {
// TODO Auto-generated constructor stub
this.carName=carName;
this.carId=carId;
this.price=price;
this.busload=busload;
}
public String getName() {
return carName;
}
public String getcarId() {
return carId;
}
public int getprice() {
return price;
}
public int getbusload() {
return busload;
}
public Car() {
// TODO Auto-generated constructor stub
}
}
package DDsystem;
public class Lorry {
private String LorryName;
private String LorryId;
private int price;
private int boatload;
public Lorry(String LorryName,String LorryId,int price,int boatload) {
// TODO Auto-generated constructor stub
this.LorryName=LorryName;
this.LorryId=LorryId;
this.price=price;
this.boatload=boatload;
}
public String getName() {
return LorryName;
}
public String getLorryId() {
return LorryId;
}
public int getprice() {
return price;
}
public int getboatload() {
return boatload;
}
public Lorry() {
}
}
package DDsystem;
public class Pickup {
private String PKName;
private String PKId;
private int price;
private int boatload;
private int busload;
public Pickup(String PKName,String PKId ,int price,int busload,int boatload) {
// TODO Auto-generated constructor stub
this.PKName=PKName;
this.PKId=PKId;
this.price=price;
this.busload=busload;
this.boatload=boatload;
}
public String getName() {
return PKName;
}
public String getcarId() {
return PKId;
}
public int getprice() {
return price;
}
public int getbusload() {
return busload;
}
public int getboatload() {
return boatload;
}
public Pickup() {
}
}
package DDsystem;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import org.omg.PortableServer.ID_ASSIGNMENT_POLICY_ID;
public class DDdache {
public List<Car> listCars;
public List<Pickup>lisPickups;
public List<Lorry>lisLorries;
public DDdache() {
this.listCars =new ArrayList<Car>();
this.lisPickups=new ArrayList<Pickup>();
this.lisLorries=new ArrayList<Lorry>();
}
public void add() {
Car car1=new Car("奥迪A4", "1",500, 4);
listCars.add(car1);
Car car2=new Car("马自达", "2",400,4);
listCars.add(car2);
Pickup pk=new Pickup("皮卡雪","3",450,4,2);
lisPickups.add(pk);
Car car3=new Car("金龙","4", 800,20);
listCars.add(car3);
Lorry lo1=new Lorry("松花江", "5", 400,4);
lisLorries.add(lo1);
Lorry lo2=new Lorry("依维柯", "6", 1000, 20);
lisLorries.add(lo2);
}
public void testShow() {
System.out.println("序号"+" " +"汽车名称 "+" "+"租金" +" "+ "容量");
for (Car car : listCars) {
System.out.println(car.getcarId()+" "+car.getName()+" "+car.getprice()+"/天 "+car.getbusload()+"人" );
}
for (Lorry lorry :lisLorries ) {
System.out.println(lorry.getLorryId()+" "+lorry.getName()+" "+lorry.getprice()+"/天 "+lorry.getboatload()+"吨" );
}
for (Pickup pick : lisPickups) {
System.out.println(pick.getcarId()+" "+pick.getName()+" "+pick.getprice()+"/天 "+pick.getbusload()+"人"+pick.getboatload()+"吨" );
}
}
public void choise() {
System.out.println("请输入租车的数量:");
Scanner scanner=new Scanner(System.in);
String s=scanner.next();
Car c1=new Car();
Lorry l1=new Lorry();
Pickup p1=new Pickup();
int money=0;
int j=Integer.parseInt(s);
System.out.println("请选择租车序列:");
for(int i=0;i<j;i++ ){
String s1=scanner.next();
for(int n=0;n<listCars.size();n++){
if(s1.equals(listCars.get(n).getcarId())){
c1=listCars.get(n);
System.out.println(c1.getcarId()+" "+c1.getName()+" "+c1.getprice()+"/天 "+c1.getbusload()+"人");
money+=c1.getprice();
break ;
}
}
for(int n=0;n<lisLorries.size();n++){
if(s1.equals(lisLorries.get(n).getLorryId())){
l1=lisLorries.get(n);
System.out.println(l1.getLorryId()+" "+l1.getName()+" "+l1.getprice()+"/天 "+l1.getboatload()+"吨");
money+=l1.getprice();
break ;
}
}
for(int n=0;n<lisPickups.size();n++){
if(s1.equals(lisPickups.get(n).getcarId())){
p1=lisPickups.get(n);
System.out.println(p1.getcarId()+" "+p1.getName()+" "+p1.getprice()+"/天 "+p1.getbusload()+"人"+p1.getboatload()+"吨" );
money+=p1.getprice();
break;
}}
}
System.out.println("您需要租几天:");
String s2=scanner.next();
int day=Integer.parseInt(s2);
money=money*day;
System.out.println("******************************");
System.out.println("订单金额: "+money);
}
public static void main(String[] args) {
System.out.println("**************************************************");
System.out.println("欢迎来到滴滴打车系统:");
DDdache ddache=new DDdache();
ddache.add();
ddache.testShow();
ddache.choise();
}
}