欢迎来到天天文库
浏览记录
ID:1537265
大小:50.06 KB
页数:7页
时间:2017-11-12
《java汽车租赁系统》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、packageRentCar;publicclassBusextendsMotoVehicle{privateintseatCount;//构造方法publicBus(){}publicBus(Stringno,Stringbrand,intseatCount){super(no,brand);this.seatCount=seatCount;}//获取座位数publicintgetSeat(){returnseatCount;}//计算租金publicintcalRent(intdays){intrent=0;if(seatCount<=16){rent=800*days;}else{r
2、ent=1500*days;}returnrent;}}……………………………………………………………………………………………………………packageRentCar;publicclassCarextendsMotoVehicle{privateStringtype;//轿车的型号//构造方法publicCar(){}publicCar(Stringno,Stringbrand,Stringtype){super(no,brand);this.type=type;}//设置轿车的型号publicvoidsetType(Stringtype){this.type=type;}//返回轿车型
3、号publicStringgetType(){returntype;}//实现父类抽象方法,计算租金publicintcalRent(intdays){intrent=0;if("宝马".equals(getBrand())){rent=days*500;}elseif("丰田".equals(getBrand())){if(type.equals("GL8")){rent=days*600;}else{rent=days*300;}}returnrent;}}……………………………………………………………………………………………………………packageRentCar;publiccla
4、ssCustomer{privateStringname;publicCustomer(){}publicCustomer(Stringname){this.name=name;}publicStringgetName(){returnname;}publicintcalcTotalRent(MotoVehicle[]moto,intdays){intrent=0;for(inti=0;i5、…………………………………………………………packageRentCar;publicabstractclassMotoVehicle{privateStringno;//车牌号privateStringbrand;//品牌//构造方法publicMotoVehicle(){}publicMotoVehicle(Stringno,Stringbrand){this.no=no;this.brand=brand;}//返回机动车辆的牌照publicStringgetNo(){returnno;}//返回机动车辆的品牌publicStringgetBrand(){returnbrand;}//6、计算租金的抽象方法publicabstractintcalRent(intdays);}……………………………………………………………………………………………………………packageRentCar;importjava.util.Scanner;publicclassTest{publicstaticvoidmain(String[]args){Scannerinput=newScanner(System.in);intdays=0;//租赁的天数intmotoType;//汽车大类型Stringbrand;//汽车品牌Stringtype=null;//汽车具体类型intseat;//7、座位数Stringno;//拍照Stringanswer;//是否继续MotoVehicle[]moto=newMotoVehicle[10];Customercustomer=newCustomer("小明");System.out.println("欢迎来到汽车租赁公司!");System.out.print("请输入要租赁的天数:");days=input.nextInt();do{System.out.print
5、…………………………………………………………packageRentCar;publicabstractclassMotoVehicle{privateStringno;//车牌号privateStringbrand;//品牌//构造方法publicMotoVehicle(){}publicMotoVehicle(Stringno,Stringbrand){this.no=no;this.brand=brand;}//返回机动车辆的牌照publicStringgetNo(){returnno;}//返回机动车辆的品牌publicStringgetBrand(){returnbrand;}//
6、计算租金的抽象方法publicabstractintcalRent(intdays);}……………………………………………………………………………………………………………packageRentCar;importjava.util.Scanner;publicclassTest{publicstaticvoidmain(String[]args){Scannerinput=newScanner(System.in);intdays=0;//租赁的天数intmotoType;//汽车大类型Stringbrand;//汽车品牌Stringtype=null;//汽车具体类型intseat;//
7、座位数Stringno;//拍照Stringanswer;//是否继续MotoVehicle[]moto=newMotoVehicle[10];Customercustomer=newCustomer("小明");System.out.println("欢迎来到汽车租赁公司!");System.out.print("请输入要租赁的天数:");days=input.nextInt();do{System.out.print
此文档下载收益归作者所有