用Java代码设计一个汽车租赁系统
时间: 2024-03-12 07:48:20 浏览: 85
好的,下面是一个简单的汽车租赁系统的Java代码示例,包含了客户管理、车辆管理、订单管理、租赁管理等功能。由于篇幅限制,这里只提供代码框架,具体实现可以根据自己的需求进行相应的修改和完善。
```java
// 客户类
public class Customer {
private String name;
private String id;
private String phone;
// 构造函数
public Customer(String name, String id, String phone) {
this.name = name;
this.id = id;
this.phone = phone;
}
// getter和setter方法
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
// 车辆类
public class Vehicle {
private String plateNumber;
private String type;
private String color;
private double price;
private double rent;
// 构造函数
public Vehicle(String plateNumber, String type, String color, double price, double rent) {
this.plateNumber = plateNumber;
this.type = type;
this.color = color;
this.price = price;
this.rent = rent;
}
// getter和setter方法
public String getPlateNumber() {
return plateNumber;
}
public void setPlateNumber(String plateNumber) {
this.plateNumber = plateNumber;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public double getRent() {
return rent;
}
public void setRent(double rent) {
this.rent = rent;
}
}
// 订单类
public class Order {
private Customer customer;
private Vehicle vehicle;
private Date rentDate;
private Date returnDate;
private double rent;
// 构造函数
public Order(Customer customer, Vehicle vehicle, Date rentDate, Date returnDate, double rent) {
this.customer = customer;
this.vehicle = vehicle;
this.rentDate = rentDate;
this.returnDate = returnDate;
this.rent = rent;
}
// getter和setter方法
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
public Vehicle getVehicle() {
return vehicle;
}
public void setVehicle(Vehicle vehicle) {
this.vehicle = vehicle;
}
public Date getRentDate() {
return rentDate;
}
public void setRentDate(Date rentDate) {
this.rentDate = rentDate;
}
public Date getReturnDate() {
return returnDate;
}
public void setReturnDate(Date returnDate) {
this.returnDate = returnDate;
}
public double getRent() {
return rent;
}
public void setRent(double rent) {
this.rent = rent;
}
}
// 租赁系统类
public class RentalSystem {
private List<Customer> customers;
private List<Vehicle> vehicles;
private List<Order> orders;
// 构造函数
public RentalSystem() {
customers = new ArrayList<Customer>();
vehicles = new ArrayList<Vehicle>();
orders = new ArrayList<Order>();
}
// 客户管理
public void addCustomer(Customer customer) {
customers.add(customer);
}
public void updateCustomer(Customer customer) {
// 根据客户id更新客户信息
}
public void deleteCustomer(String id) {
// 根据客户id删除客户信息
}
public Customer findCustomer(String id) {
// 根据客户id查找客户信息
return null;
}
// 车辆管理
public void addVehicle(Vehicle vehicle) {
vehicles.add(vehicle);
}
public void updateVehicle(Vehicle vehicle) {
// 根据车牌号更新车辆信息
}
public void deleteVehicle(String plateNumber) {
// 根据车牌号删除车辆信息
}
public Vehicle findVehicle(String plateNumber) {
// 根据车牌号查找车辆信息
return null;
}
// 订单管理
public void addOrder(Order order) {
orders.add(order);
}
public void updateOrder(Order order) {
// 根据订单号更新订单信息
}
public void deleteOrder(String id) {
// 根据订单号删除订单信息
}
public Order findOrder(String id) {
// 根据订单号查找订单信息
return null;
}
// 租赁管理
public boolean rentVehicle(String id, String plateNumber, Date rentDate, Date returnDate) {
// 根据客户id和车牌号出租车辆
return false;
}
public boolean returnVehicle(String id, String plateNumber, Date returnDate) {
// 根据客户id和车牌号归还车辆
return false;
}
// 统计报表
public List<Order> getOrderReport(Date startDate, Date endDate) {
// 根据日期范围生成订单报表
return null;
}
public double getIncomeReport(Date startDate, Date endDate) {
// 根据日期范围生成收入报表
return 0.0;
}
}
```
以上是一个简单的汽车租赁系统的Java代码示例,您可以根据自己的需求进行相应的修改和完善。
阅读全文