汽车租赁系统采用Java语言编写

----------------------------------------------------------------该代码亲试有效,欢迎各位dalao对代码不足处,提出建议,留言评论。

----------------------------------------------------------------本人QQ:2149810847

主要实现功能

1.    客户租两种不同的车,轿车和客车

2.    根据日租金和天数计算租金

3.    租赁多量车时计算总金额

主要方法

1.    抽象出汽车类,有子类为轿车类和客车类

2.    抽象方法为计算租金函数,和展示汽车基本信息函数

3.    轿车类有车名,皮牌,车牌号,车的数量,日租金等属性

4.    客车类有车名,皮牌,车牌号,车的数量,日租金,座位数等属性

5.    系统服务类,客户类。

6.    系统服务类有客户名单,轿车对象数组,客车对象数组,

7.    客户有登陆系统的root,password

package car_rental;
import java.io.*;
import java.util.*;abstract class Car{protected String carName;   //车的名字protected String carLabel;    //品牌protected String carNumber;    //车牌号protected int number_of_car;    //车的数量abstract double getRentPrice(int day);abstract void displayInfo();
}class Small_car extends Car{private double dayRent;//static int number_of_car = 0;Small_car(){}Small_car(String carName, int dayRent, String carLabel, String carNumber, int number_of_car){this.carName = carName;//this.dayRent = dayRent;this.carLabel = carLabel;this.carNumber = carNumber;this.number_of_car = number_of_car;}void displayInfo() {System.out.println(this.carName + "        " + this.carLabel + "       " + this.carNumber + "      "+ this.dayRent + "     " + this.number_of_car);}double getRentPrice(int day){return this.dayRent * day;}
}class Passenger_car extends Car{private int carSeat;private double dayRent1;private double dayRent2;Passenger_car(){}Passenger_car(String carName, double dayRent1, double dayRent2, String carLabel, String carNumber,int carSeat, int number_of_car){this.carName = carName;//this.dayRent1 = dayRent1;this.dayRent2 = dayRent2;this.carLabel = carLabel;this.carNumber = carNumber;this.carSeat = carSeat;this.number_of_car = number_of_car;}void displayInfo() {System.out.print(this.carName + "        " + this.carLabel + "       " + this.carNumber + "      "+ this.carSeat + "     " + this.number_of_car + "      ");if (this.carSeat > 16)System.out.println(this.dayRent2);else System.out.println(this.dayRent1);}@Overridedouble getRentPrice(int day){if (this.carSeat > 16)return this.dayRent2 * day;else return this.dayRent1 * day;}
}class Car_client{String clientName;String password;double price;static double allPrice = 0.0;Car_client(){}void setName(String clientName) {this.clientName = clientName;}void setPassword(String password) {this.password = password;}char chooseServe(char flag) {if (flag == '0')System.out.println("clientName = " + this.clientName + "\tALL price = " + this.allPrice);return flag;}int chooseCar() {Scanner sc =new Scanner(System.in);int number = sc.nextInt();return number;}int chooseDay() {Scanner sc =new Scanner(System.in);int day = sc.nextInt();return day;}}class Car_serve_system{Small_car sCar[];Passenger_car pCar[];Car_client client;void Serve(char flag) {if (flag == '0')this.exitSystem();if (flag == '1')this.display_scar();if (flag == '2')this.display_pcar();}void login() {System.out.println("欢迎登录汽车租赁系统");}void mainWindow() {System.out.println("                 *****欢迎进入汽车租赁系统*****                    ");}void initCar() {sCar = new Small_car[10];pCar = new Passenger_car[3];sCar[0] = new Small_car("本田CRV", 600, "宝马", "京NY28588", 2);sCar[1] = new Small_car("福特", 500, "宝马", "京1234567", 3);sCar[2] = new Small_car("本田HRV", 400, "宝马", "京1000000", 3);sCar[3] = new Small_car("本田CRV", 600, "别克", "京NT43765", 4);sCar[4] = new Small_car("福特", 500, "别克", "京2000000", 5);sCar[5] = new Small_car("本田HRV", 400, "别克", "京3000000", 6);sCar[6] = new Small_car("本田CRV", 600, "金龙", "京5643765", 0);sCar[7] = new Small_car("福特", 500, "金龙", "京N565656", 9);sCar[8] = new Small_car("本田HRV", 400, "金龙", "京7777777", 10);sCar[9] = new Small_car("本田CRV", 600, "宝马", "京NNN3284", 2);pCar[0] = new Passenger_car("<=16座", 800, 1000, "ZK6535DX", "京123", 15, 15);pCar[1] = new Passenger_car(">16座", 800, 1000, "ZK6809DX", "京123", 25, 2);pCar[2] = new Passenger_car(">16座", 800, 1000, "T7(V6)汽油版", "京123", 40, 5);}void display_scar() {System.out.println("车的名字" + "     " + "车的品牌" + "        " + "车牌号" + "     "+ "日租费" +"       "+ "可租的数量");for (Small_car sc : sCar){sc.displayInfo();}System.out.print("请选择第几辆车租借:");}void display_pcar() {System.out.println("车的名字" + "     " + "车的品牌" + "            " + "车牌号" + "     "+ "车座数" + "      " + "可租的数量" + "       " + "日租费");for (Passenger_car pc : pCar) {pc.displayInfo();}System.out.print("请选择第几辆车租借:");}void exitSystem() {System.exit(0);   //}void give_s_car(int flag) {if (sCar[flag-1].number_of_car > 0) {System.out.print("请选择租借天数:");this.client.price = this.sCar[flag-1].getRentPrice(this.client.chooseDay());this.sCar[flag-1].number_of_car--;System.out.println("price = " + this.client.price);this.client.allPrice += this.client.price;}else {System.out.print("该车已经全部被出租!请另外选择!");this.give_s_car(this.client.chooseCar());}
}void give_p_car(int flag) {if (pCar[flag-1].number_of_car > 0) {System.out.print("请选择租借天数:");this.client.price = this.pCar[flag-1].getRentPrice(this.client.chooseDay());this.pCar[flag-1].number_of_car--;System.out.println("price = " + this.client.price);this.client.allPrice += this.client.price;}else {System.out.print("该车已经全部被出租!请另外选择!");this.give_s_car(this.client.chooseCar());}}}public class Rent_car{public static void main(String[] args) throws IOException {// TODO Auto-generated method stubScanner sc =new Scanner(System.in);   //raedCar_serve_system carSystem = new Car_serve_system();Car_client carClient = new Car_client();carSystem.client = carClient;carSystem.login();System.out.print("please write your name:");carClient.setName(sc.nextLine());System.out.print("please write your password:");carClient.setPassword(sc.nextLine());carSystem.initCar();carSystem.mainWindow();char flag = 'a';while (flag != '0') {   //while true :System.out.println("   0:退出" + "         " +"1:租轿车" + "          " + "2:租客车    ");flag = (char)System.in.read();carSystem.Serve(carClient.chooseServe(flag));if (flag == '1') {carSystem.give_s_car(carClient.chooseCar());}elsecarSystem.give_p_car(carClient.chooseCar());}}
}

汽车租赁系统(Java)相关推荐

  1. 基于javaweb的汽车租赁系统(java+ssm+jsp+layui+echarts+mysql)

    基于javaweb的汽车租赁系统(java+ssm+jsp+layui+echarts+mysql) 运行环境 Java≥8.MySQL≥5.7.Tomcat≥8 开发工具 eclipse/idea/ ...

  2. Java窗体汽车租赁系统Java共享汽车租赁(租赁系统)

    Java窗体汽车租赁系统Java共享汽车租赁(租赁系统)

  3. 汽车租赁系统java基于数据库_基于数据库和JAVA的网上汽车租赁管理系统的设计(MySQL)...

    基于数据库和JAVA的网上汽车租赁管理系统的设计(MySQL)(论文11000字,程序代码,MySQL数据库) 摘要:本文用JAVA编程语言为主体,用JDBC连接MySQL数据库来设计和实现这个系统. ...

  4. Java项目:汽车租赁系统(java+SSM+JSP+LayUI+echarts+mysql)

    源码获取:博客首页 "资源" 里下载! ssm汽车租赁系统 carRental 系统概要 汽车租赁系统总共分为两个大的模块,分别是系统模块和业务模块.其中系统模块和业务模块底下又有 ...

  5. 汽车租赁系统java窗口_共享型汽车租赁系统(SSM+MySql)

    知乎视频​www.zhihu.com 共享型汽车租赁系统(SSM+MySql)的设计与实现(毕业论文14000字以上,程序代码,MySQL数据库) [项目包含内容] [文档包含内容] [项目功能描述] ...

  6. javaswing汽车租赁系统 java swing mysql实现的汽车租赁系统源码和导入文档(1002)

    java swing + mysql 汽车租车管理系统(1002) 1.系统运行环境 运行环境:Java8 + MySQL8 开发工具:eclipse/idea 2.系统功能实现 (下面介绍的功能肯定 ...

  7. 基于JAVA+SpringMVC+Mybatis+MYSQL的汽车租赁系统

    项目功能: 系统概要 汽车租赁系统总共分为两个大的模块,分别是系统模块和业务模块.其中系统模块和业务模块底下又有其子模块. 系统分为四类用户角色:超级管理员.业务管理员.系统管理员.数据统计管理员.角 ...

  8. JAVA汽车租赁系统(JAVA毕业设计)

    前言 课设毕设源码收集已上传到github,地址:https://github.com/52JDK/Source-Collection 如果对大家有用的话欢迎点个star,本文源码请直接到文章末尾 简 ...

  9. 基于JAVA汽车租赁系统计算机毕业设计源码+系统+lw文档+部署

    基于JAVA汽车租赁系统计算机毕业设计源码+系统+lw文档+部署 基于JAVA汽车租赁系统计算机毕业设计源码+系统+lw文档+部署 本源码技术栈: 项目架构:B/S架构 开发语言:Java语言 开发软 ...

  10. 基于JAVA汽车租赁系统计算机毕业设计源码+数据库+lw文档+系统+部署

    基于JAVA汽车租赁系统计算机毕业设计源码+数据库+lw文档+系统+部署 基于JAVA汽车租赁系统计算机毕业设计源码+数据库+lw文档+系统+部署 本源码技术栈: 项目架构:B/S架构 开发语言:Ja ...

最新文章

  1. ThreadLocalRandom 安全吗
  2. c++ 获取时间字符串
  3. python 爬虫工具
  4. python真的好吗-python的缩进格式真的不好吗?
  5. 《入门经典》——6.24
  6. 文件共享同步5种方式:NFS、NAS、rsync、scp、ftp
  7. idea mac 替换_Mac软件IntelliJ IDEA 上的快捷键,让你的工作更加顺畅
  8. 信安教程第二版-第19章操作系统安全保护
  9. nodejs从服务器返回静态文件,nodejs静态资源服务器
  10. mysql数据库基础知识--一分钟让你数据库入门(sql基础语法篇)
  11. linux 海思hi3798m_海思Hi3798M V310芯片简介
  12. 一篇关于微信防撤回(文本、图片、语音、视频、名片等...)的Python学习教程
  13. android 脚本发短信,Android使用Intent发送短信的实现方法
  14. 计算机画图简笔画竹子,竹子简笔画图片教程
  15. python之文件处理
  16. 阿里巴巴达摩院又被点名表扬了,这一次是要“拯救世界”?
  17. win10安装mysql8.0,一台电脑上安装多个mysql
  18. Java随笔记 - Java代码实现一个死锁程序
  19. 矩形法_加工难题:双头深矩形螺旋槽
  20. 从零开始仿写一个抖音App——音视频开篇,移动安全入门

热门文章

  1. js(jquery)提交表单,必填内容为空,边框变红
  2. Android启动模式SingleInstance
  3. 计算机待机原理,电脑待机原理和开机原理
  4. 有限元基础及ANSYS应用 - 第3节 - 平面桁架结构有限元分析 - PPT
  5. 数据库期末复习题总汇
  6. 《大型网站技术架构:核心原理与案例分析》之读书笔记
  7. 华为[ENSP]VLAN常用配置命令
  8. 数字电路_1. 逻辑门表达式 真值表
  9. IMX6ULL SPI
  10. 学哪种编程语言比较好?