汽车租赁管理系统(java)–隔壁小河

代码亲测有效,各位大佬就不用看了吧,小白看过来呀
一个简单的汽车租赁问题,分为四个类:父类CarHire,子类Bus和Vehicle,再加一个业务类(Service).测试类我可能写的有点复杂
------QQ1942295707;欢迎交流

import java.util.Scanner;abstract class CarHire {String number;//车牌号String brand;//品牌int rent;//租金CarHire(){}CarHire(String number, String brand, int rent){this.number = number;this.brand = brand;this.rent = rent;}public String getBrand() {return brand;}public int getRent() {return rent;}public String getNumber() {return number;}public abstract int calRent(int days);//计算租金的抽象函数
}class Bus extends CarHire{int setCount;//客车座位数public Bus() {}public Bus(int setCount, String number, String brand, int rent) {super(number, brand, rent);this.setCount = setCount;}public int calRent(int days) {int price;if (setCount <= 16)price = days*800;elseprice = days*1000;return price;}}class Vehicle extends CarHire{String  type;public Vehicle() {}public Vehicle(String number, String brand, int rent, String type) {super(number, brand, rent);this.type = type;}public int calRent(int days) {int price;price=days*rent;return price;}public String getType() {return type;} }class Service{Vehicle [] motos0 = new Vehicle[4];Bus [] motos1 = new Bus[4];Vehicle rentService0=null;Bus rentService1=null;public void init1() {motos0[0]=new Vehicle("京NY28688", "宝马", 880, "林荫大道");motos0[1]=new Vehicle("京JB38589", "别克", 990, "X9");motos0[2]=new Vehicle("京DJ52166", "宝马", 600, "GL9");motos0[3]=new Vehicle("京LI78956", "别克", 300, "500i");}public void init2() {//汽车的初始化数据motos1[0]=new Bus(16,"京89888", "金龙", 800);motos1[1]=new Bus(34,"京85688", "金龙", 1500);motos1[2]=new Bus(16,"京68974", "金杯", 800);motos1[3]=new Bus(34,"京96854", "金杯", 1500);}public Vehicle rentService(String brand, String type){init1();Vehicle rentService0 = new Vehicle();for (int i=0; i<motos0.length; i++) {if (type.equals(motos0[i].getType()) && brand.equals(motos0[i].getBrand())){rentService0=motos0[i];break;}}return rentService0;}public Bus rentService(String brand, int rent){init2();Bus rentService1 = new Bus();for (int i=0; i<motos1.length; i++) {if (rent == motos1[i].getRent() &&  brand.equals(motos1[i].getBrand())){rentService1=motos1[i];break;}}return rentService1;}
}public class Car {public static void main(String[] args) {String brand="";//品牌String type="";//轿车型号int rent=0;//租金Scanner input = new Scanner (System.in);System.out.println("欢迎来到汽车租赁系统:\n请选择汽车车型:1.轿车     2.客车");int choose;//记录选择的汽车车型choose = input.nextInt();boolean flag = false;//用来记录选的是轿车还是客车switch(choose) {case 1://flag = false;System.out.println("请选择轿车的品牌:1.宝马      2.别克");int flash0 = input.nextInt();switch(flash0) {case 1:brand="宝马";System.out.println("请选择宝马的型号:1.林荫大道     2.GL9");int book0 = input.nextInt();//book0 记录选择if (book0 == 1) {type="林荫大道";break;}if (book0 == 2) {type = "GL9";break;}elseSystem.out.println("输入错误,请输入1或2选择");break;case 2:brand = "别克";System.out.println("请选择别克的型号:1.X9     2.500i");       int book1 = input.nextInt();//book1 记录选择if (book1 == 1) {type="X9";break;}if (book1 == 2) {type = "500i";break;}elseSystem.out.println("输入错误,请输入1或2选择");break;}break;case 2:flag = true;System.out.println("请输入客车的型号:1.金龙     2.金杯");int flash1 = input.nextInt();switch(flash1) {case 1:brand = "金龙";System.out.println("请选择金龙的座位数:1.<=16个座位     2.>16个座位");int book2 = input.nextInt();//book3 记录选择if (book2 == 1) {rent= 800;break;}if (book2 == 2) {rent = 1500;break;}elseSystem.out.println("输入错误,请输入1或2选择");break;case 2:brand = "金杯";System.out.println("请选择金杯的座位数:1.<=16个座位数     2.>16个座位数");int book3 = input.nextInt();//book4 记录选择if (book3 == 1) {rent = 800;break;}if (book3 == 2) {rent = 1500;break;}else {System.out.println("输入错误,请输入1或2选择");break;  }default: System.out.println("输入错误!请输入1或2");}break;default: System.out.println("输入错误!请输入1或2");}Service book = new Service();//这里的book记录Service的行为int money;String number;System.out.println("请输入租赁的天数:");int days = input.nextInt();if (flag == false) {//计算租金money = book.rentService(brand, type).calRent(days);number = book.rentService(brand, type).getNumber();//调用轿车的函数}else {money = book.rentService(brand, rent).calRent(days);number = book.rentService(brand, rent).getNumber();//调用卡车的函数}System.out.println("**********您好!租车结果如下**********");System.out.println("租车成功!您的车是:" + number + " " + brand + " " + type);System.out.println("您应付的金额为:" + money);}
}

汽车租赁管理系统(java)--隔壁小河相关推荐

  1. [附源码]SSM计算机毕业设计汽车租赁管理系统-JAVA

    项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclis ...

  2. 基于SSM+Vue汽车租赁管理系统Java车辆出租系统(源码调试+讲解+文档)

  3. Java 汽车租赁管理系统

    Java 汽车租赁管理系统 数据库配置说明xmsql -- ---------------------------- -- Table structure for car -- ----------- ...

  4. java毕业生设计新能源汽车租赁管理系统计算机源码+系统+mysql+调试部署+lw

    java毕业生设计新能源汽车租赁管理系统计算机源码+系统+mysql+调试部署+lw java毕业生设计新能源汽车租赁管理系统计算机源码+系统+mysql+调试部署+lw 本源码技术栈: 项目架构:B ...

  5. [附源码]计算机毕业设计JAVA新能源汽车租赁管理系统

    [附源码]计算机毕业设计JAVA新能源汽车租赁管理系统 项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(I ...

  6. [附源码]java毕业设计新能源汽车租赁管理系统

    项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclis ...

  7. java计算机毕业设计新能源汽车租赁管理系统源码+数据库+系统+lw文档+mybatis+运行部署

    java计算机毕业设计新能源汽车租赁管理系统源码+数据库+系统+lw文档+mybatis+运行部署 java计算机毕业设计新能源汽车租赁管理系统源码+数据库+系统+lw文档+mybatis+运行部署 ...

  8. java计算机毕业设计新能源汽车租赁管理系统源程序+mysql+系统+lw文档+远程调试

    java计算机毕业设计新能源汽车租赁管理系统源程序+mysql+系统+lw文档+远程调试 java计算机毕业设计新能源汽车租赁管理系统源程序+mysql+系统+lw文档+远程调试 本源码技术栈: 项目 ...

  9. [附源码]java毕业设计汽车租赁管理系统-

    项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclis ...

  10. Java汽车租赁管理系统

    要求: (1)设计汽车租赁管理系统,实现汽车租赁信息的管理,可对系统中的车辆进行添加.删除.修改: (2)按所选设计任务在eclipse下进行项目的开发设计,最终展示界面可以普通输入输出界面. 2.设 ...

最新文章

  1. luogu P3410 拍照(最大权闭合图转最小割)
  2. httpclient get post
  3. 转:Bit-Map思想与2-BitMap思想
  4. linux ntfs硬盘自动挂,linux下查看所有硬盘分区+挂接NTFS磁盘/硬盘+自动挂接硬盘方法...
  5. eos节点服务器_EOS跌落神坛?
  6. 【深度学习系列】卷积神经网络CNN原理详解(一)——基本原理(1)
  7. Java scirpt简介
  8. github+hexo搭建博客(一)
  9. js 日期操作 (转载:http://blog.sina.com.cn/s/blog_699d2e170101q6iz.html)
  10. 独角兽影视APP系统源码/双端影视APP源码
  11. SkeyeARS 超高清8K视频录像检索、 回放、控制解决方案
  12. Audition 如何录制电脑内部声音
  13. MI(mutal information)and Entropy
  14. 漫反射(diffuse reflection)
  15. html做群聊通讯方法,微信如何发起群聊邀请(微信群链接生成教程)
  16. mpeg怎么转换成mp4?
  17. DNS云学堂 | 三分钟了解,最近大火的DOH与HTTPDNS、DOT的异同
  18. Qt OpenGL 旋转、平移、缩放
  19. python题库刷题网站_python在线刷题网站
  20. 【方法】Marvell 88W8801 WiFi模块创建能上网的热点

热门文章

  1. 国内三大知名开源B2B2C多用户商城系统对比
  2. 国服游戏封包解密-外挂制作全过程
  3. 软件项目设计文档分类
  4. 基于RSSI及KNN算法的WiFi室内定位实现
  5. ssci源刊里有开源期刊吗_ssci源刊里有开源期刊吗_啥是核心期刊?啥是北核啥是南核?啥是国家级?啥又是省级?都给你整明白......
  6. vb在服务器上新建文件夹,VB 创建文件夹
  7. 【无人机】【2008.09】用于小型无人机目标定位的轨迹优化
  8. 《电路》邱关源 思维导图 第四章-电路定理
  9. 服务器如何备份系统和配置,windows server 2008和2012如何设置完整备份+增量备份
  10. 直播带货系统,实现直播间人数统计