基于java的汽车租赁管理系统,java简单汽车租赁系统代码
本文分享java实现一个简单的汽车租赁系统的具体代码,供大家参考。具体内容如下
欢迎来到xx汽车租赁公司。请输入用户名和密码(默认用户名为首字母,密码为123,登录模块封装到方法中调用方法)。请输入您的操作。1)查看现在车库里的所有车辆信息。2)租车。3)给车库加一辆车。4)修改租车价格信息。
用switch去判断操作
阶级分析
代码:
包com . you JIU ye . BMS;public class CRMS { public static void main(String[]args){ Wellcome();} public static void Wellcome(){ system . out . println( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *);system . out . println( tw elcome to He Boss Library );system . out . println( * * * * * * * * * * * * * * * * * * * * * * * * * * * * *);//获取用户信息tool . input info();} }包com . you JIU ye . BMS;/* *租车系统功能模块类* 1、管理员在车库添加车辆信息* 2、用户租赁车辆* 3、用户查看车库车辆* 4、用户查看自己租赁的车辆* 5、管理员修改车辆价格* 6、用户结算租金*/public类CRMSService {//1、管理员公共布尔添加车辆(moto vehicle mo)的车库添加车辆信息{ boolean bo=falseMotoVehicel[]ms=MotoVehicel . getms();if(ms . length 0){ for(int I=0;长度;I){ if(ms[I]==null){ ms[I]=mo;bo=真;System.out.println(成功添加!);打破;} } }返回bo;} //2.用户租用车辆Public Void Rent (Users U,Moto Vehicle Mo){ Moto Vehicle[]ms=U . Getums();for(int I=0;长度;I){ if(ms[I]==null){ ms[I]=mo;打破;}}}}//4.用户查看他们租用的车辆公共布尔浏览(users u){ boolean bo=false;MotoVehicel[]mo=u . getums();if(mo . length 0){ for(int I=0;i mo.lengthi ) { if(mo[i]!=null){ system . out . println(mo[I].toString());bo=真;} } }返回bo;} //5.管理员修改车辆公共布尔更新的价格(string no,double price){ boolean bo=false;if(MotoVehicel . array exit()){ MotoVehicel[]ms=MotoVehicel . getms()
; for (int i = 0; i < ms.length; i++) { if(ms[i] != null && ms[i].getNo().equals(no)){ ms[i].setRentPrice(price); System.out.println("修改成功!"); System.out.println(ms[i]); bo = true; } } }else{ System.out.println("当前车库中还没有车辆"); } return bo; } // 6、用户结算租金 public double settleAccount(Users u,int days){ double price = 0; MotoVehicel[] mo = u.getUms(); if(mo.length > 0){ for (int i = 0; i < mo.length; i++) { if(mo[i] != null){ price += mo[i].getRentPrice() * days; } } } return price; } // 删除车库中的车辆 public void delete(MotoVehicel moo){ MotoVehicel[] mo = MotoVehicel.getMs(); if(mo.length > 0){ for (int i = 0; i < mo.length; i++) { if(mo[i] != null && mo[i].equals(moo)){ mo[i] = null; } } } } // 根据车牌号来判断车库中是否含有该车辆 public boolean judgeExitMotoVehicel(String no){ boolean bo = false; MotoVehicel[] ms = MotoVehicel.getMs(); if(ms.length >0){ for (int i = 0; i < ms.length; i++) { if(ms[i].getNo().equals(no)){ bo = true; break; } } } return bo; }}
package com.youjiuye.bms;/* * 汽车租赁系统的功能模块类 * 1、管理员添加车库中的车辆信息 * 2、用户租赁车辆 * 3、用户查看车库中的车辆 * 4、用户查看自己租赁的车辆 * 5、管理员修改车辆的价格 * 6、用户结算租金 */public class CRMSService { // 1、管理员添加车库中的车辆信息 public boolean addVehicel(MotoVehicel mo){ boolean bo = false; MotoVehicel[] ms = MotoVehicel.getMs(); if(ms.length > 0){ for (int i = 0; i < ms.length; i++) { if(ms[i] == null){ ms[i] = mo; bo = true; System.out.println("添加成功!"); break; } } } return bo; } // 2、用户租赁车辆 public void rent(Users u,MotoVehicel mo){ MotoVehicel[] ms = u.getUms(); for (int i = 0; i < ms.length; i++) { if(ms[i] == null){ ms[i] = mo; break; } } } // 4、用户查看自己租赁的车辆 public boolean browse(Users u){ boolean bo = false; MotoVehicel[] mo = u.getUms(); if(mo.length > 0){ for (int i = 0; i < mo.length; i++) { if(mo[i] != null){ System.out.println(mo[i].toString()); bo = true; } } } return bo; } // 5、管理员修改车辆的价格 public boolean update(String no,double price){ boolean bo = false; if(MotoVehicel.arrayExit()){ MotoVehicel[] ms = MotoVehicel.getMs(); for (int i = 0; i < ms.length; i++) { if(ms[i] != null && ms[i].getNo().equals(no)){ ms[i].setRentPrice(price); System.out.println("修改成功!"); System.out.println(ms[i]); bo = true; } } }else{ System.out.println("当前车库中还没有车辆"); } return bo; } // 6、用户结算租金 public double settleAccount(Users u,int days){ double price = 0; MotoVehicel[] mo = u.getUms(); if(mo.length > 0){ for (int i = 0; i < mo.length; i++) { if(mo[i] != null){ price += mo[i].getRentPrice() * days; } } } return price; } // 删除车库中的车辆 public void delete(MotoVehicel moo){ MotoVehicel[] mo = MotoVehicel.getMs(); if(mo.length > 0){ for (int i = 0; i < mo.length; i++) { if(mo[i] != null && mo[i].equals(moo)){ mo[i] = null; } } } } // 根据车牌号来判断车库中是否含有该车辆 public boolean judgeExitMotoVehicel(String no){ boolean bo = false; MotoVehicel[] ms = MotoVehicel.getMs(); if(ms.length >0){ for (int i = 0; i < ms.length; i++) { if(ms[i].getNo().equals(no)){ bo = true; break; } } } return bo; }}
package com.youjiuye.bms;public class Users { private String identity; private String password; // 存放租赁的车辆信息 private MotoVehicel[] ums = new MotoVehicel[10]; public MotoVehicel[] getUms() { return ums; } public void setUms(MotoVehicel[] ums) { this.ums = ums; } public Users(){} public Users(String identity, String password) { super(); this.identity = identity; this.password = password; } public String getIdentity() { return identity; } public void setIdentity(String identity) { this.identity = identity; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString() { return "Users [identity=" + identity + ", password=" + password + "]"; }}
package com.youjiuye.bms;/* * 所有车的父类 * */public abstract class MotoVehicel { private String no; private String brand; private String Color; private int mileage; private double rentPrice; private static MotoVehicel[] ms= new MotoVehicel[10]; public MotoVehicel(){} public MotoVehicel(String no, String brand, String color, int mileage, double rentPrice) { super(); this.no = no; this.brand = brand; Color = color; this.mileage = mileage; this.rentPrice = rentPrice; } public String getNo() { return no; } public void setNo(String no) { this.no = no; } public String getBrand() { return brand; } public void setBrand(String brand) { this.brand = brand; } public String getColor() { return Color; } public void setColor(String color) { Color = color; } public int getMileage() { return mileage; } public void setMileage(int mileage) { this.mileage = mileage; } public double getRentPrice() { return rentPrice; } public void setRentPrice(double rentPrice) { &
郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。