# 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); }