From 1601d39e291ffae6fabb589d1b303d5ba79c32af Mon Sep 17 00:00:00 2001 From: Fuyuxinge <1876397977@qq.com> Date: Thu, 2 Apr 2026 13:56:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4w4=E5=92=8C=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- w4/Car.java | 0 w4/TestCar.java | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 w4/Car.java create mode 100644 w4/TestCar.java diff --git a/w4/Car.java b/w4/Car.java new file mode 100644 index 0000000..e69de29 diff --git a/w4/TestCar.java b/w4/TestCar.java new file mode 100644 index 0000000..c008f31 --- /dev/null +++ b/w4/TestCar.java @@ -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()); + } +}