



全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
实现租车汽车租赁系统,不同车型日租金情况如表7-1所示;车型及日期轿车客车车型别克Gl8宝马750别克凯越19座日租金(元/天)7506005008001200编程实现计算不同车型不同天数的租赁费用。package zuche;public abstract class MotoVehicle private String no;private String brand; int fee= 750,600,500,800,1200;public MotoVehicle() public MotoVehicle(String no,String brand) this.no=no; this.brand=brand;public String getNo() return no;public String getBrand() return brand;public void setBrand(String brand) this.brand=brand;public void setNo(String no) this.no=no;public void printInfo() System.out.println(*汽车的信息*+n汽车品牌+this.brand+n车牌号+this.no);public abstract void calRent(int days) ;package zuche;public class Car extends MotoVehicle private String type; /String type1= 别克凯越,宝马730,别克凯越,中小客车(19座以内),大型客车(19座以上);public Car() public Car(String no,String brand,String type) super(no,brand);this.type=type;public String getType() return type;public void setType(String type) this.type=type; public void printInfo() /super.printInfo();/调用父类的构造方法,子类不能直接继承父类的构造方法;System.out.println(*汽车的信息*+n汽车品牌+getBrand()+n型号+this.type+n车牌号+getNo();public void calRent(int days) int rent=0; if(宝马.equals(getBrand() rent=days*600; else if(别克.equals(getBrand()&gl8.equals(this.type) rent=days*750; else rent=days*500; System.out.println( 你的租车费用为+rent+元);package zuche;public class Bus extends MotoVehicleprivate int seatCount;public Bus() public int getSeatCount() return seatCount;public void setSeatCount(int seatCount) this.seatCount=seatCount;public void printInfo() System.out.println(*汽车的信息*+n车牌号+getNo()+n客车座位数+this.seatCount+座);public void calRent(int days) int rent=0;if(seatCount=19) rent=days*800;else rent=days*1200;System.out.println(你的租车费用为+rent+元);package zuche;import java.util.Scanner;public class TestRent public static void main(Stringargs) Scanner input=new Scanner(System.in);/int carType;String answer;int day=0;Car c=new Car();Bus b=new Bus();System.out.println(*欢迎光临西树东花租车*);System.out.println(*);int random=(int)(Math.random()*89999+10000);/random()的取值范围为0,1);do System.out.println(轿车请选:1+n货车请选:2);c.setNo(黑At+random);if(input.nextInt()=1) System.out.println(请输入汽车的品牌(1.宝马、2.别克);switch(input.nextInt() case 1: c.setBrand(宝马);c.setType(730); c. printInfo();System.out.println(请输入租车天数);c.calRent(input.nextInt();break; case 2: System.out.println(请选择别克车的类型:gl8、凯越); if(input.nextInt()=1)c.setBrand(别克); c.setType(gl8); c. printInfo(); System.out.println(请输入租车天数); c.calRent(input.nextInt();else c.setBrand(别克);c.setType(凯越);c. printInfo(); System.out.println(请输入租车天数); c.calRent(input.nextInt();else System.out.println(请选择客车的座位数:19座下/19座以上);b.setNo(黑A+random);switch(input.nextInt() case 1:b.setSeatCount(17); b.printInfo(); System.out.println(请输入租车天数); b.calRent(input.nextInt(); break;case 2: b.setSeatCount(21); b.printInfo(); System.out.println(请输入租车天数); b.calRent(
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 智能化安全编排策略-洞察及研究
- 造价咨询市场询价方案
- 社交焦虑认知干预策略-洞察及研究
- 短程依赖的几何表示学习-洞察及研究
- 2025年4月重庆医科大学附属第三医院招聘医师、医技、护理、行政、其他岗位考前自测高频考点模拟试题及1套参考答案详解
- 2025年临沂莒南县教体系统部分事业单位公开招聘教师(1名)考前自测高频考点模拟试题及答案详解(夺冠)
- 2025广西南宁上林县禁毒委员会招聘禁毒社工1人模拟试卷及参考答案详解
- 人类进化与基因多样性-洞察及研究
- 稀土元素吸附机理-洞察及研究
- 生育率变化与劳动力市场的关系-洞察及研究
- 《预防校园霸凌》课件
- 共用检验设备协议书
- 采砂作业合同协议
- 《2025年CSCO宫颈癌诊疗指南》更新要点解读
- 2024-2030全球铝制遮阳系统行业调研及趋势分析报告
- 部编版小学六年级道德与法治上册单元测试试题含答案(全册)
- 施工单位在城市更新项目中的角色与职责
- 竞选纪律委员演讲稿
- 2024年10月广东高等教育自学考试05175税收筹划试题及答案
- 人教版四年级数学上册第一次月考综合测评卷(1-2单元)(含答案)
- 215kWh工商业液冷储能电池一体柜用户手册
评论
0/150
提交评论