From 84067b91181a680031a15aabaddc4633535458eb Mon Sep 17 00:00:00 2001 From: JiangYouhan <3080587852@qq.com> Date: Sun, 22 Mar 2026 17:32:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20'w3/=E5=AE=9E=E9=AA=8C?= =?UTF-8?q?=E6=8A=A5=E5=91=8A.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- w3/实验报告.md | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 w3/实验报告.md diff --git a/w3/实验报告.md b/w3/实验报告.md deleted file mode 100644 index 08e2ac6..0000000 --- a/w3/实验报告.md +++ /dev/null @@ -1,29 +0,0 @@ -# Java实验报告:车辆管理系统中的Car类 - -## 一、实验目的 -1. 巩固封装的基本实现:私有属性 + 公有getter/setter -2. 练习构造方法的重载以及this关键字的作用 -3. 掌握在业务方法中加入数据校验,保护对象状态的合法性 -4. 能够编写测试类验证类的功能 - -## 二、类图 - -## 三、核心代码 - -### 1. 构造方法重载 -```java -// 全参构造 -public Car(String licensePlate, String brand, String model, double dailyRent) { - this.licensePlate = licensePlate; - this.brand = brand; - this.model = model; - this.dailyRent = dailyRent; - this.isRented = false; - totalCars++; -} - -// 三参构造(使用this()调用全参构造) -public Car(String licensePlate, String brand, String model) { - this(licensePlate, brand, model, 300.0); -} -