JAVA-实现汽车租赁系统的计价功能

1. MotoVehicleE

/*** @author Jensen* @data 2022/11/4* @usage*/
public abstract class MotoVehicleE {private String no;private String brand;/*** 无参构造方法。*/public MotoVehicleE(){}/*** 有参构造方法。* no ; 汽车牌号* brand ; 汽车品牌*/public MotoVehicleE(String no, String brand){this.no = no;this.brand = brand;}/*** 租赁天数* @param days* @return*/public abstract int callRent(int days);}

2. CarE Class

/*** @author Jensen* @data 2022/11/4* @usage*/
public final class CarE extends MotoVehicleE{private String type;/*** 无参构造方法*/public CarE(){}public CarE(String type,String no, String brand){super(no,brand);this.type = type;}/*** 获取车辆类型* @param type*/public void setType(String type){this.type = type;}public String getType() {return type;}/*** 这里的callRent只要继承了就是必须要强制重写的* @param days* @return*/@Overridepublic int callRent(int days){if ("1".equals(type)){return days * 500;} else if ("2".equals(type)) {return days * 600;}else {return days * 300;}}
}

3. BusE Class

/*** @author Jensen* @data 2022/11/4* @usage*/
public final class BusE extends MotoVehicleE{private int seatCount;/*** 无参构造方法*/public BusE(){}/*** 这里是有参构造方法* @param seatCount* @param brand* @param no*/public BusE(int seatCount,String brand, String no){super(brand, no);this.seatCount = seatCount;}/*** 设置座位数* @param seatCount*/public void setSeatCount(int seatCount){this.seatCount = seatCount;}public int getSeatCount() {return seatCount;}/*** 这里的callRent只要继承了就是必须要强制重写的* @param days* @return*/@Overridepublic int callRent(int days) {if (seatCount <= 15 ){return days*800;}else {return days*1500;}}
}

4. TestRentE Class

import java.util.Random;
import java.util.Scanner;/*** @author Jensen* {@code @data} 2022/11/4*/
public class TestRentE {public static Random random = new Random();public static final Scanner scanner = new Scanner(System.in);public static String getCarNumber(){StringBuilder sb = new StringBuilder("粤B");for (int i = 0; i<5;i++){if(random.nextInt(2)==0){sb.append((char)(random.nextInt(26)+65));}else {sb.append(random.nextInt(10));}}return sb.toString();}public static void start(){System.out.println(">>>欢迎您来到汽车租赁公司: ");System.out.println(">>>请输入要租几天: ");int days = scanner.nextInt();System.out.println(">>>请输入租赁汽车类型: \n1.轿车\t2.客车");String carType = scanner.next();int rent;if ("1".equals(carType)){System.out.println("1. 宝马\t2. 别克");String brand = scanner.next();String type;if ("1".equals(brand)){System.out.println(">>>您选择的型号是: 530i");type = "宝马-530i";}else {System.out.println("2.商务舱GL8 \t 3. 林荫大道");type = scanner.next();}String no = getCarNumber();System.out.println(">>>给您分配的汽车牌号是: "+no);MotoVehicleE carE = new CarE(type,no,brand);rent = carE.callRent(days);}else {System.out.println(">>>请输入租赁客车的品牌: \n1.金杯\t2.金龙");String brand = scanner.next();System.out.println(">>>请输入需要座位数量: ");int seatCount = scanner.nextInt();String no = getCarNumber();MotoVehicleE busE = new BusE(seatCount,brand,no);rent = busE.callRent(days);System.out.println(">>>给您分配的汽车牌号是: "+no);}System.out.println("\n顾客您好,你需要支付的租赁费用是: "+rent+".");}public static void main(String[] args) {start();}
}

总结

  1. 这里面还是有很多问题和缺陷,只是记录一下作业学习
  2. 参考文献:
    https://blog.csdn.net/qq_29163727/article/details/115079357?spm=1001.2014.3001.5506

JAVA-实现汽车租赁系统的计价功能相关推荐

  1. 实现汽车租赁系统的计价功能

    package careBorrow; /*** 汽车设为父类* */ public abstract class Car {protected static String no;protected ...

  2. java毕业设计汽车租赁系统演示录像源码+lw文档+mybatis+系统+mysql数据库+调试

    java毕业设计汽车租赁系统演示录像源码+lw文档+mybatis+系统+mysql数据库+调试 java毕业设计汽车租赁系统演示录像源码+lw文档+mybatis+系统+mysql数据库+调试 本源 ...

  3. java毕业设计汽车租赁系统mybatis+源码+调试部署+系统+数据库+lw

    java毕业设计汽车租赁系统mybatis+源码+调试部署+系统+数据库+lw java毕业设计汽车租赁系统mybatis+源码+调试部署+系统+数据库+lw 本源码技术栈: 项目架构:B/S架构 开 ...

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

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

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

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

  6. java springboot汽车租赁系统小程序-uniapp

    .系统主要包括系统首页.个人中心.用户管理.驾驶证管理.车辆品牌管理.车辆信息管理.预约租赁管理.汽车租赁管理.还车信息管理.费用结算管理.系统管理等功能模块. 任何系统都要遵循系统设计的基本流程,本 ...

  7. Java编写汽车租赁系统

    题目要求: 1.汽车租赁信息表如下: 2.类和属性: 3.运行效果: 效果实现: 代码实现: 1.车类: package homework.exam;public abstract class Veh ...

  8. 汽车租赁系统(2)-完成登录功能

    文章目录 完成汽车租赁系统的登录功能 分析登录功能: 创建数据库的表 用户表(sys_users) 创建首页index.jsp 创建实体类 创建UserVo 创建Mapper 创建Mapper.xml ...

  9. 【计算机毕业设计】303汽车租赁系统

    一.系统截图(需要演示视频可以私聊) 摘要 近年来,信息化管理行业的不断兴起,使得人们的日常生活越来越离不开计算机和互联网技术.首先,根据收集到的用户需求分析,对设计系统有一个初步的认识与了解,确定汽 ...

最新文章

  1. mysql远程连接问题
  2. label实现不同大小不同颜色
  3. 在 Linux 上模拟系统负载
  4. JAX-WS使用Handler实现简单的WebService权限验证
  5. Oracle查询日期
  6. mysql interval 3 day_Mysql之INTERVAL与DATE_SUB与EXTRACT函数的使用
  7. 数据结构实验之排序三:bucket sort
  8. 解析UML的要点与应用
  9. WAVE族函数的使用
  10. 命主属性是水什么意思_跟水有关的字女孩名字寓意她们柔美水灵-可爱点
  11. 数据绑定的优点_轻松应对海量数据,TiDB 在车好多的实践
  12. 局域网联通公网小部分知识点
  13. 新手学习电脑知识的一些方法
  14. Python检测字符串是否只含“空白字符”
  15. 小白成为大数据工程师 需掌握哪些知识技能
  16. 小米NFC手机 手环 复制加密IC门禁卡
  17. 《Multi-Scale Residual Learning-using a Cycle Spinning CNN for Single Image De-Raining》
  18. 【linux】lsb_release -a命令
  19. 如何查询一个IP上所绑定的域名
  20. 绝地求生体验服服务器修复吗,绝地求生测试服1月24日更新内容 修复滑步

热门文章

  1. luogu小金明qwq x
  2. unity修改asset store及其他缓存位置
  3. 5分钟玩转Axure之快速创建Chart图表
  4. 京东H5小游戏《疯狂足球》Android外挂实现
  5. PMSM弱磁控制的电压、电流极限圆幅值的含义
  6. 舰炮火控设备模拟与测试系统的设计
  7. 3D立体相册模板(大小可更改)
  8. android:手机各大分区详解
  9. 树莓派实践系列2-人体红外感应传感器、声音传感器、红外避障传感器
  10. rpc wmi 服务不可用_“RPC服务器不可用”使用WMI查询