Carrent
Carrent
com/yuenci/Java-Car-Rental-System
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.ArrayList;
class Customer {
this.name = name;
this.gender = gender;
this.address = address;
return name;
return gender;
return address;
}
@Override
return name;
class Car {
this.plateNumber = plateNumber;
this.destination = destination;
this.rentDate = rentDate;
this.returnDate = returnDate;
return plateNumber;
return destination;
}
public String getRentDate() {
return rentDate;
return returnDate;
@Override
return plateNumber;
class CarRental {
public CarRental() {
cars.add(car);
cars.remove(index);
}
customers.add(customer);
customers.remove(index);
return cars;
return customers;
this.carRental = carRental;
carList.addItem(car);
customerList.addItem(customer);
rentButton.addActionListener(new ActionListener() {
carRental.removeCar(carIndex);
carRental.removeCustomer(customerIndex);
updateCarList();
updateCustomerList();
});
returnButton.addActionListener(new ActionListener() {
updateCarList();
updateCustomerList();
});
add(carLabel);
add(carList);
add(customerLabel);
add(customerList);
add(rentButton);
add(returnButton);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setVisible(true);
carList.addItem(car);
customerList.removeAllItems();
customerList.addItem(customer);