- Project Overview
- Features
- Technologies Used
- Database Schema
- Project Structure
- Getting Started
- Usage
- API Endpoints
- Custom Exceptions
- Unit Testing
- Contributing
- License
The Car Rental System is a full-stack web/mobile application designed to manage a car rental business. The system includes features for managing cars, customers, leases, and payments. This project focuses on the use of object-oriented programming, database interaction via SQL, control flow statements, loops, exception handling, and unit testing.
- Customer Management: Add, update, and retrieve customer details.
- Car Management: Add new cars, update availability, and view available/rented cars.
- Lease Management: Create daily or monthly leases and calculate lease costs.
- Payment Handling: Record payments and retrieve payment history.
- Exception Handling: Handles custom exceptions for invalid operations.
- Unit Testing: Includes tests to ensure system correctness and reliability.
- Java (Backend)
- MySQL (Database)
- JDBC (Database Connectivity)
- JUnit (Testing)
- Maven (Build Automation)
- Spring Boot (Optional: For creating REST APIs)
- Frontend: HTML, CSS, JavaScript (for web app) or Android Studio (for mobile app)
The system uses the following SQL schema:
-
Vehicle Table:
vehicleID
(Primary Key)make
,model
,year
,dailyRate
status
(available/notAvailable)passengerCapacity
,engineCapacity
-
Customer Table:
customerID
(Primary Key)firstName
,lastName
,email
,phoneNumber
-
Lease Table:
leaseID
(Primary Key)vehicleID
(Foreign Key)customerID
(Foreign Key)startDate
,endDate
,type
(Daily/Monthly)
-
Payment Table:
paymentID
(Primary Key)leaseID
(Foreign Key)paymentDate
,amount
src/
├── entity/model
│ ├── Car.java
│ ├── Customer.java
│ ├── Lease.java
│ ├── Payment.java
├── dao
│ ├── ICarLeaseRepository.java
│ ├── ICarLeaseRepositoryImpl.java
├── exception
│ ├── CarNotFoundException.java
│ ├── CustomerNotFoundException.java
│ ├── LeaseNotFoundException.java
├── util
│ ├── DBPropertyUtil.java
│ ├── DBConnUtil.java
├── main
│ ├── MainModule.java
├── test
│ ├── CarRentalTest.java
- Java 11+
- MySQL
- Maven
- JDBC Driver for MySQL
- JUnit for testing
After running the application, use the console or frontend to navigate through the following menu options:
- Add, update, and list customers.
- Add, update, and view cars.
- Create and manage car leases.
- Record and view payments.
(Optional for Spring Boot-based applications)
POST /cars
: Add a new car.GET /cars/available
: List available cars.POST /leases
: Create a new lease.POST /payments
: Record a payment.
- CarNotFoundException: Thrown when a car ID doesn't exist in the database.
- LeaseNotFoundException: Thrown when a lease ID doesn't exist.
- CustomerNotFoundException: Thrown when a customer ID doesn't exist.
Unit tests are included to ensure system correctness. Key tests include:
- Car creation success test.
- Lease creation and retrieval tests.
- Exception handling tests for invalid IDs.