使用java实现汽车租赁系统的案例

  介绍

这篇文章给大家分享的是有关使用java实现汽车租赁系统的案例的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

具体内容如下

使用java实现汽车租赁系统的案例

//车类   public  abstract  class  Vehicle  {   ,//车牌号,,品牌,,日租金   ,private  String  id;   ,private  String 品牌;   ,private  int  perRent;   ,   ,public 车辆(){}   ,//车辆的带参构造方法   ,public 车辆(String  id, String 品牌,int  perRent), {=,this.id  id;=,this.brand 品牌;=,,this.perRent  perRent;   ,}   ,   ,public  void  setId (String  id) {   ,this.id=id ;   ,}   ,public  String  getId () {   ,return  id;   ,}   ,   ,public  void  setBrand (String 品牌){   ,this.brand=品牌;   ,}   ,public  String  getBrand () {   ,return 品牌;   ,}   ,   ,public  void  setPerRent (int  perRent) {   ,this.perRent=perRent;   ,}   ,public  int  getPerRent () {   ,return  perRent;   ,}   ,//抽象方法计算租金   ,public  abstract  double  calcRent (int 天);   ,   }   ,//轿车类   public  class  Car  extends 车辆{   ,//型号   ,private  String 类型;   ,public  void  setType (String 类型){   ,this.type=类型;   ,}   ,public  String 方法(){   ,return 类型;   ,}   ,   ,public 汽车(){}   ,//汽车的带参构造方法   ,public 汽车(String  id, String 品牌,int  perRent, String 类型),{   ,超级(id、品牌perRent);=,this.type 类型;   ,}   ,//重写父类的计算租金方法:根据自己的计算租金规则   ,public  double  calcRent (int 天),{   ,double  price =, this.getPerRent() *天;   7,如果(days>,,,, days<=30) {   price 才能;*=,0.9;   ,}else 如果(days> 30,,,, days<=150) {   price 才能;*=,0.8;   ,}else 如果(days> 150) {   price 才能;*=,0.7;   ,}   ,return 价格;   ,}   }   ,//客车类   public  class  Bus  extends 车辆{   ,//座位数   ,private  int  seatCount;   ,public  void  setSeatCount (int  seatCount) {   ,this.seatCount=seatCount;   ,}   ,public  int  getSeatCount () {   ,return  seatCount;   ,}   ,   ,   ,public 总线(){}   ,//总线的带参构造方法   ,public 总线(String  id, String 品牌,int  perRent, int  seatCount) {   ,超级(id、品牌perRent);=,,this.seatCount  seatCount;   ,}   ,//重写父类的计算租金方法:根据自己的计算租金规则   ,public  double  calcRent (int 天),{   ,double  price =, this.getPerRent() *天;   ,如果(days>=3,,,, days<7) {   price 才能;*=,0.9;   ,}else 如果(days>=7,,,, days<30) {   price 才能;*=,0.8;   ,}else 如果(days>=30,,,, days<150) {   price 才能;*=,0.7;   ,}else 如果(days> 150) {   price 才能;*=,0.6;   ,}   ,return 价格;   ,   ,}   }   ,//汽车业务类   public  class  Operation  {   车辆,public  [], vehicle =, new 车辆[8];//初始化汽车信息   ,public  void  init () {   ,汽车[0]=,new 汽车(“京NY28588",“宝马“,800年,“X6");,,//vehicle  v =, new 汽车();   ,汽车[1]=,new 汽车(“京32584元“,“宝马“,600年,“550我),,,//vehicle  v =, new 汽车();   ,汽车[2]=,new 汽车(“京NT37465",“别克“,300年,“林荫大道“);,,//vehicle  v =, new 汽车();   ,汽车[3]=,new 汽车(“京NT96968",“别克“,600年,“GL8");,,//vehicle  v =, new 汽车();   ,汽车[4]=,new 总线(“京6566754“,“金杯“,800年,16);,,//vehicle  v =, new 总线();   ,汽车[5]=,new 总线(“京8696997“,“金龙“,800年,16);,,//vehicle  v =, new 总线();   ,汽车[6]=,new 总线(“京9696996“,“金杯“,1500年,34);,,//vehicle  v =, new 总线();   ,汽车[7]=,new 总线(“京8696998“,“金龙“,1500年,34);,,//vehicle  v =, new 总线();   ,}   ,//租车:根据用户提供的条件去汽车数组中查找相应车辆并返回   ,//如果租赁的是轿车,,需要条件:品牌,,,,型号   ,//如果租赁的是客车,,需要条件:品牌,,,,座位数   ,//简单工厂模式   ,public  Vehicle  zuChe (int  String  String 品牌;类型;seatCount) {   ,Vehicle  che =,空;   ,//循环遍历数组车辆   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

使用java实现汽车租赁系统的案例