/client/
package didi;
import java.util.Scanner;
public class Client {
public static void main(String[] args) {
Car[] cars={
new MannedCar("奥迪A4",4,500),
new MannedCar("马自达6",4,500),
new Pickup("皮雪卡6", 2, 4, 450),
new MannedCar("金龙",20,800),
new Trunk("松花江",4,400),
new Trunk("依维柯",20,1000)
};
// TODO Auto-generated method stub
System.out.println("欢迎使用租车系统");
System.out.println("您是否要租车?");
Scanner in = new Scanner(System.in);
int input = in.nextInt();
if(input==0){
System.out.println("下次光临");
System.exit(0);
}
else if(input==1){
for(int i=0;i<cars.length;i++){
System.out.print(i+":");
cars[i].getList();
System.out.println();
}
}
System.out.println("请输入你想租车的数量");
Scanner in_1 = new Scanner(System.in);
int num = in_1.nextInt();
Car[] cars1 = new Car[num];
for(int i=0;i<num;i++){
System.out.println("第"+(i+1)+"辆为:");
Scanner in_2 = new Scanner (System.in);
cars1[i]=cars[in_2.nextInt()];
}
System.out.println("请输入租车的天数");
Scanner in_3 = new Scanner(System.in);
int day = in_3.nextInt();
System.out.println("总价为:");
int sum=0;
for(int i=0;i<num;i++){
sum+=cars1[i].getRent();
}
sum=sum*day;
System.out.print(sum+"元");
}
}
点击查看更多内容
1人点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦