You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
2.0 KiB
51 lines
2.0 KiB
package com.rental;
|
|
|
|
public class TestCar {
|
|
public static void main(String[] args) {
|
|
System.out.println("===== 车辆管理系统测试 =====\n");
|
|
|
|
Car car1 = new Car("京A12345", "大众", "朗逸", 200.0);
|
|
Car car2 = new Car("沪B67890", "丰田", "凯美瑞", 350.0);
|
|
Car car3 = new Car("粤C24680", "本田", "雅阁");
|
|
|
|
System.out.println("=== 创建的车辆信息 ===");
|
|
car1.displayInfo();
|
|
car2.displayInfo();
|
|
car3.displayInfo();
|
|
|
|
System.out.println("\n=== 测试租车功能 ===");
|
|
System.out.println("对车辆1进行租车操作:");
|
|
car1.rentCar();
|
|
System.out.println("再次尝试租车:");
|
|
car1.rentCar();
|
|
|
|
System.out.println("\n=== 测试还车功能 ===");
|
|
System.out.println("对车辆1进行还车操作:");
|
|
car1.returnCar();
|
|
System.out.println("再次尝试还车:");
|
|
car1.returnCar();
|
|
|
|
System.out.println("\n=== 测试租金计算 ===");
|
|
System.out.println("车辆2租用5天的费用:" + car2.calculateRent(5) + " 元");
|
|
System.out.println("车辆3租用3天的费用:" + car3.calculateRent(3) + " 元");
|
|
|
|
System.out.println("\n=== 测试setter数据校验 ===");
|
|
System.out.println("尝试将车辆1的日租金设置为-100:");
|
|
car1.setDailyRent(-100);
|
|
System.out.println("车辆1当前日租金:" + car1.getDailyRent());
|
|
System.out.println("将车辆1的日租金设置为250:");
|
|
car1.setDailyRent(250);
|
|
System.out.println("车辆1当前日租金:" + car1.getDailyRent());
|
|
|
|
System.out.println("\n=== 测试品牌和型号修改 ===");
|
|
car1.setBrand("奥迪");
|
|
car1.setModel("A4");
|
|
System.out.println("修改后的车辆1信息:");
|
|
car1.displayInfo();
|
|
|
|
System.out.println("\n=== 车辆总数统计 ===");
|
|
System.out.println("总车辆数:" + Car.getTotalCars() + " 辆");
|
|
|
|
System.out.println("\n=== 测试完成 ===");
|
|
}
|
|
}
|