到后面好像把自己绕晕了。想输出租车的具体账单和金额,但是不知道如何建立联系了。新手一枚,求大神指教
package zuche.com;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Car[] information={new PassengerCar("劳斯莱斯","500元/天",4)
,new PassengerCar("拉沙马蒂","600元/天",2),new PassengerCar("兰博基尼","800/天",2)
,new Pickup("皮卡","300元/天",2,4),new Pickup("路虎","500/天",4,4)
,new Trunk("松花江","800元/天",5)
,new Trunk("依维柯","1000元/天",20)
};
System.out.println("欢迎使用嗒嗒租车行:");
System.out.println("你是否需要租车:1是 0否");
Scanner scanner=new Scanner(System.in);
String input=scanner.next();
if(input.equals("1")){
System.out.println("你可租用的车的类型及价格等");
System.out.println("序号\t 汽车名称\t租金\t载客量\t载重量\t");
int i=1;
for(Car c:information){
if(c instanceof PassengerCar){
System.out.println(""+i+"\t"+c.getName()+"\t"+c.getRent()
+"\t"+c.getNumber()+"人");
}else if(c instanceof Trunk){
System.out.println(""+i+"\t"+c.getName()+"\t"+c.getRent()
+"\t"+"\t"+c.getWeight()+"吨");
}else{
System.out.println(""+i+"\t"+c.getName()+"\t"+c.getRent()
+"\t"+c.getNumber()+"人"+"\t"+c.getWeight()+"吨");
}
i++;
}
System.out.println("请输入你要租车的数量");
int e=scanner.nextInt();
if(e<0||e>10){
System.out.println("你的输入有误,设为默认值1");
e=1;
}
for (int a = 1; a <=e; a++) {
System.out.println("请输入第"+a+"量车的序号");
Scanner scanner2 = new Scanner(System.in);
int o = scanner2.nextInt();
}
System.out.println("请输入租车的天数");
Scanner scanner3=new Scanner(System.in);
int day=scanner3.nextInt();
if(day>0){
System.out.println("你的账单:");
}
}