《2022年java汽车租赁系统.pdf》由会员分享,可在线阅读,更多相关《2022年java汽车租赁系统.pdf(9页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、package RentCar;publicclass Bus extends MotoVehicleprivateintseatCount ;quals(getBrand()rent = days * 500;elseif ( 丰田.equals(getBrand()if ( GL8)rent = days * 600;精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 1 页,共 9 页 - - - - - - - - - - else rent = days * 300;return rent;pack
2、age RentCar;publicclass Customer private String name ;public Customer()精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 2 页,共 9 页 - - - - - - - - - - public Customer(String name) = name;public String getName()returnname ;publicint calcTotalRent(MotoVehicle moto, int days)int rent
3、 = 0 ;for ( int i = 0 ;i ; i+)if (motoi!=null )rent = rent + motoi.calRent(days);精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 3 页,共 9 页 - - - - - - - - - - return rent;package RentCar;publicabstractclass MotoVehicle private String no; 车 2. 客车): );motoType = ();int random = (
4、int )()*(99999-10000)+10000);switch (motoType)精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 4 页,共 9 页 - - - - - - - - - - case 1: no = 粤A + random; 马 2. 丰田): );if () = 1)brand = 宝马;type = 320i ;else brand = 丰田; type = RAV4;海 2. 金龙): );/ 根据选择得到汽车品牌if () =1)brand = 黄海;else 精品资料
5、- - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 5 页,共 9 页 - - - - - - - - - - brand = 金龙;请输入客车的座位数: );seat = (); / 汽车座位数/ 实例化一个轿车对象 , 并添加到 moto数组中for ( int i = 0 ; i ;i +)if (motoi = null )motoi = new Bus(no,brand,seat); / 实例化一个汽车对象break ;break;精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢
6、迎下载 名师归纳 - - - - - - - - - -第 6 页,共 9 页 - - - - - - - - - - 是否继续租车( y/n ): );answer = ();while (y );汽车牌号 t 汽车品牌 );for ( int i = 0 ; i ;i +)if (motoi != null )if (motoi instanceof Car)Car c = (Car)motoi;t+();else Bus b = (Bus)motoi;t+();精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - -
7、- -第 7 页,共 9 页 - - - - - - - - - - 客户名: +()+ , 租赁天数: +days+, 总费用: +(moto, days);package RentCar;publicclass Truck extends MotoVehicle privateintweight ; / 吨位public Truck()精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 8 页,共 9 页 - - - - - - - - - - public Truck(String no, String brand,int weight)super (no,brand); = weight;publicint getWeight()returnweight ;publicint calRent(int days)int rent = 0; rent = weight * 50 * days;return rent;精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 9 页,共 9 页 - - - - - - - - - -