汽车修理管理系统java
时间: 2023-10-23 15:12:35 浏览: 61
对于汽车修理管理系统的开发,你可以使用Java语言来实现。下面是一个简单的汽车修理管理系统的Java代码示例:
```java
import java.util.ArrayList;
import java.util.List;
class Car {
private String brand;
private String model;
private int year;
private String color;
// 构造函数
public Car(String brand, String model, int year, String color) {
this.brand = brand;
this.model = model;
this.year = year;
this.color = color;
}
// 获取品牌
public String getBrand() {
return brand;
}
// 获取型号
public String getModel() {
return model;
}
// 获取年份
public int getYear() {
return year;
}
// 获取颜色
public String getColor() {
return color;
}
}
class RepairShop {
private List<Car> carList;
public RepairShop() {
carList = new ArrayList<>();
}
// 添加汽车到修理厂
public void addCar(Car car) {
carList.add(car);
}
// 移除汽车从修理厂
public void removeCar(Car car) {
carList.remove(car);
}
// 获取修理厂内的所有汽车
public List<Car> getAllCars() {
return carList;
}
}
public class CarRepairSystem {
public static void main(String[] args) {
RepairShop repairShop = new RepairShop();
// 创建汽车对象
Car car1 = new Car("Toyota", "Camry", 2020, "White");
Car car2 = new Car("Honda", "Accord", 2019, "Black");
// 添加汽车到修理厂
repairShop.addCar(car1);
repairShop.addCar(car2);
// 获取修理厂内的所有汽车
List<Car> cars = repairShop.getAllCars();
// 打印汽车信息
for (Car car : cars) {
System.out.println("Brand: " + car.getBrand());
System.out.println("Model: " + car.getModel());
System.out.println("Year: " + car.getYear());
System.out.println("Color: " + car.getColor());
System.out.println();
}
}
}
```