2 changed files with 36 additions and 0 deletions
@ -0,0 +1,36 @@ |
|||||
|
package w4; |
||||
|
|
||||
|
|
||||
|
public class TestCar { |
||||
|
public static void main(String[] args) { |
||||
|
Car car1 = new Car("京A12345", "丰田", "凯美瑞", 450.0); |
||||
|
Car car2 = new Car("沪B67890", "大众", "帕萨特"); |
||||
|
Car car3 = new Car("粤C54321", "宝马", "3系", 680.0); |
||||
|
|
||||
|
System.out.println("=====初始车辆信息====="); |
||||
|
car1.displayInfo(); |
||||
|
car2.displayInfo(); |
||||
|
car3.displayInfo(); |
||||
|
|
||||
|
|
||||
|
System.out.println("=====测试租车还车====="); |
||||
|
car1.rentCar(); |
||||
|
car1.rentCar(); |
||||
|
car1.returnCar(); |
||||
|
car1.returnCar(); |
||||
|
System.out.println(); |
||||
|
|
||||
|
|
||||
|
System.out.println("=====计算5天租金====="); |
||||
|
double rent = car2.calculateRent(5); |
||||
|
System.out.println("车辆2租用5天总费用:" + rent + "元\n"); |
||||
|
|
||||
|
|
||||
|
System.out.println("=====测试非法修改租金====="); |
||||
|
car3.setDailyRent(-100); |
||||
|
System.out.println(); |
||||
|
|
||||
|
System.out.println("=====车辆总数统计====="); |
||||
|
System.out.println("系统中总车辆数:" + Car.getTotalCars()); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue