欢迎来到天天文库
浏览记录
ID:53865264
大小:15.42 KB
页数:5页
时间:2020-04-09
《汽车租赁系统-java.docx》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、实现租车汽车租赁系统,不同车型日租金情况如表7-1所示;车型及日期轿车客车车型别克Gl8宝马750别克凯越<=19座>19座日租金(元/天)7506005008001200编程实现计算不同车型不同天数的租赁费用。packagezuche;publicabstractclassMotoVehicle{privateStringno;privateStringbrand;int[]fee={750,600,500,800,1200};publicMotoVehicle(){}publicMotoVehicle(Stringno,Stringbrand){this.no=no;this.
2、brand=brand;}publicStringgetNo(){returnno;}publicStringgetBrand(){returnbrand;}publicvoidsetBrand(Stringbrand){this.brand=brand;}publicvoidsetNo(Stringno){this.no=no;}publicvoidprintInfo(){System.out.println("***汽车的信息***"+"汽车品牌"+this.brand+"车牌号"+this.no);}publicabstractvoidcalRent(intdays)
3、;}packagezuche;publicclassCarextendsMotoVehicle{privateStringtype;//String[]type1={"别克凯越","宝马730","别克凯越","中小客车(19座以内)","大型客车(19座以上)"};publicCar(){}publicCar(Stringno,Stringbrand,Stringtype){super(no,brand);this.type=type;}publicStringgetType(){returntype;}publicvoidsetType(Stringtype){this.typ
4、e=type;}publicvoidprintInfo(){//super.printInfo();//调用父类的构造方法,子类不能直接继承父类的构造方法;System.out.println("***汽车的信息***"+"汽车品牌"+getBrand()+"型号"+this.type+"车牌号"+getNo());}publicvoidcalRent(intdays){intrent=0;if("宝马".equals(getBrand())){rent=days*600;}elseif("别克".equals(getBrand())&&"gl8".equals(thi
5、s.type)){rent=days*750;}else{rent=days*500;}System.out.println("你的租车费用为"+rent+"元");}}packagezuche;publicclassBusextendsMotoVehicle{privateintseatCount;publicBus(){}publicintgetSeatCount(){returnseatCount;}publicvoidsetSeatCount(intseatCount){this.seatCount=seatCount;}publicvoidprintInfo(){Syst
6、em.out.println("***汽车的信息***"+"车牌号"+getNo()+"客车座位数"+this.seatCount+"座");}publicvoidcalRent(intdays){intrent=0;if(seatCount<=19){rent=days*800;}else{rent=days*1200;}System.out.println("你的租车费用为"+rent+"元");}}packagezuche;importjava.util.Scanner;publicclassTestRent{publicstaticvoidmain(String[]
7、args){Scannerinput=newScanner(System.in);//intcarType;Stringanswer;intday=0;Carc=newCar();Busb=newBus();System.out.println("**欢迎光临西树东花租车**");System.out.println("***********************");intrandom=(int)(Math.random()*89999+10000);//rand
此文档下载收益归作者所有