下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、汽车租赁系统-java实现租车汽车租赁系统,不同车型日租金情况如表 7-1所示;车型及日期轿车客车车型别克Gl8宝马750别克凯越<=19 座>19座日租金(元/7506005008001200天)编程实现计算不同车型不同天数的租赁费用。package zuche;public abstract class MotoVehicle privateStringno;privateStringbrand ;int fee = 750,600,500,800,1200;public MotoVehicle() public MotoVehicle(Stri ngno ,Stri ng b
2、rand) this . no=no; this . brand =brand ;public Stri ng getNo() return no;public Stri ng getBra nd() returnbrand ;public void setBrand(Stringbrand ) this . brand =brand ;public void setNo(Stringno) this . no=no;public void printInfo() System. out .println( "* 汽车的信息 *" +"n 汽车品牌"+t
3、his .brand +"n 车牌号"+this .no);public abstract void calRent( int days);package zuche;public class Car extends MotoVehicle private String type ;/Stringtype 1= "别克凯越","宝马730","别克凯越","中小客车(19座以内)","大型客车(19座以上)"public Car() public Car(String no
4、,Stringbrand ,String type ) super ( no, brand );this . type =type ;public String getType() return type ;public thistype ) void setType(String .type =type ; publicvoid printInfo() /super.pri ntl nfo();造方法;System. out .println( "* 号"+this . type +"n 车牌号 public void calRent( intintif Cre
5、ntelse".equals(getBrand()&&rent else rentIIIISystem.package zuche;调用父类的构造方法,子类不能直接继承父类的构汽车的信息*"+getNo();days) rent =0;宝马".equals(getBrand()+"n 汽车品牌"+getBrand()+"n 型=days *600; if ("别克"gl8" .equals( this . type )=days *750;=days *500;out .println(
6、" 你的租车费用为"+rent +"元");public class Bus extends MotoVehicle private int seatCount ;public Bus() public int getSeatCo un t() returnseatCount ; public this publicvoid setSeatCount( int seatCount ) .seatCount =seatCount ;void printInfo() System. out .println( "* 汽车的信息 *" +&
7、quot;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; im public publicclass TestRent static
8、void main(String args ) Sca nner in put =new Scann er(System.in );/int carType;Stringanswer;int day =0;Car c=new Car();"*欢迎光临西树东花租车H*“*");Bus b=new Bus();System. out .println( System. out .println(in0t random =(int )(Math.,1);do System.c.setNo("黑At" +random); if (in putran dom ()
9、*89999+10000);/ran dom()的取值范围为out .println("轿车请选:1" +"n货车请选:2");System. out .println(.n extI nt()=1) "请输入汽车的品牌(1.宝马、2.别克)");switch (in put .n ext In t() case 1:c.setBrand("宝马");c.setType( "730");c. prin tI nfo();System. out .println("请输入租车天数&quo
10、t;);c.calRe nt( in put .n ext In t();break ;case 2:System. out .println("请选择别克车的类型:if (in put .n ext In t()=1)c.setBrand("别克");gl8、凯越");c.setType( "gl8");c. prin tI nfo();System. out .println( "请输入租车天数"); c.calRe nt(in put .n extI nt(); else c.setBrand("别
11、克");c.setType("凯越");c. prin tI nfo();System. out .println( "请输入租车天数"); c.calRe nt(in put .n extI nt();else System. out .println( b.setNo("黑A"+random); switch (in put .n ext In t() case 1: b.setSeatCount(17);"请选择客车的座位数:19座下/19座以上")b.pri ntl nfo();System. out .println("请输入租车天数");b.calRe nt( in put .n ext In t();break ;case 2:b.setSeatCou nt(21);b.pri ntl nfo();System. out .println( "请输入租车天数");b.calRe nt(in put .n ext In t();
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 人教版八年级语文上册《桥之美》课件
- 做账实操-成本控制计划执行后数据评估分析
- 特种设备严重事故隐患判定标准
- 安徽省宿州市五校2021-2022学年物理高一第二学期期末预测试题含解析
- 2022年之江教育评价物理高一第二学期期末学业质量监测模拟试题含解析
- 六年级品德第一单元课件
- 2022年西藏林芝第二高级中学物理高一第二学期期末经典模拟试题含解析
- 机械设计基础 第4版 s专业词汇
- 2024年酶法生产海藻糖项目规划申请报告模板
- 新中国建立72周年
- 中国式现代化为主题的论文3000字(1) (1)全文
- 5《大学之道》《人皆有不忍人之心》理解性默写(含答案) 统编版高中语文选择性必修上册
- 2024年全国高考新课标真题卷物理及答案
- DL∕T 1894-2018 电力光纤传感器通 用规范
- 学生学习兴趣培养方案三篇
- 安全生产法律法规清单(2024年5月版)
- GB/Z 44071-2024液压传动连接软管总成操作规程
- 酒吧厨房承包合同
- 2024北京市赛导游理论考试题库(含答案)
- 灭火机器人毕业设计
- DL-T5333-2021水电水利工程爆破安全监测规程
评论
0/150
提交评论