0
点赞
收藏
分享

微信扫一扫

【JAVA语言面向对象】(25)租赁系统

张宏涛心理 2022-02-28 阅读 74

1. 代码实现

点击进入(不含付费内容)

2. 项目分析

分析:

系统有几类研究对象

租赁系统RentalSystem

宝马  Car{

  属性

     型号 String model

     车牌 String cardNo

     品牌  String brand

   

  方法

     public int calcRent(int day){//计算租金

                   //

}

}

客车  Bus{

   属性

     座位数  int seat

     车牌   String cardNo;

     品牌   String brand;

   方法

    public int calcRent(int day){

                   //

}

}

发现有公共的属性和方法,向上抽取父类

机动车辆

MotoVehicle{

   共同的属性

   共同的方法

   如果父类方法统一化的,就在父类实现,否则设计抽象方法

}

Car extends  ..{

   特有的属性

   特有的方法

   重写方法

}

Bus …..

RentalSystem{

       public void showInfo(){

      // 输出

}

   public void mainInterface(){

      //欢迎。。。。

      //输出。。。。。

}

}

Test测试类。

步骤

1. MotoVehicle类

2. Car类

3. TestCar

4. Bus

5. Test Bus

6. RentalSystem

7. 测试

举报

相关推荐

0 条评论