Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 51 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,101 +1,89 @@
# Vehicle-Rental-System
The Vehicle Rental System. It simulates a basic rental service where users can rent, return, and view vehicles such as cars, motorcycles, and trucks.
# 🚗 Vehicle Rental System

A simple GUI-based Java application to manage a vehicle rental system using OOP concepts. It allows users to rent and return vehicles, view available vehicles, and track rentals through a unique rental ID.

---

## 🧩 Features
## 📌 Features

- Add and manage different types of vehicles
- Create and manage customer profiles
- Rent and return vehicles
- Track vehicle availability
- Console-based interaction with organized class structure
- Rent vehicles (Car / Motorcycle)
- Return rented vehicles using Rental ID
- View available vehicles
- Unique rental ID generation (e.g., RC5, RM3)
- Basic input validation and error handling
- GUI with colorful modern buttons and font styling

---

## 🔧 Technologies Used

- Java
- OOP concepts
## 🧱 Technologies Used

- Java (JDK 8 or higher)
- Swing for GUI
- OOP Concepts (Encapsulation, Inheritance, Composition)
- IntelliJ

## 🗂️ Purpose of Each Folder
---

| Folder | Purpose |
|-------------|--------------------------------------------------------------------|
| `ui/` | All Swing GUI components and user-facing windows |
| `models/` | All data model classes representing vehicles, customers, etc. |
| `system/` | Contains backend logic — rental management, data storage, etc. |
| `.gitignore`| Prevents unnecessary files (like `.class`, `bin/`, `.idea/`) from upload |
| `README.md` | GitHub project info, setup guide, usage instructions |
## 🗂️ Project Structure

VehicleRentalSystem/
├── models/ # Vehicle, Car, Motorcycle, Customer classes
├── system/ # RentalSystem, DataStore classes
├── ui/ # GUI interfaces (MainMenuUI, RentalFormUI, ReturnFormUI, UIDesign )
└── VehicleRentalSystem.java # Entry point of the application


---

````markdown
## 🚀 How to Clone and Run This Project in VS Code
## 🚀 How to Run

Follow these steps to clone the Vehicle Rental System and run it using Visual Studio Code.
1. Clone the repository or download the ZIP.
2. Open the project in your preferred Java IDE.
3. Compile the entire project.
4. Run `VehicleRentalSystem.java` to launch the application.

---

### 📥 1. Clone the Repository
## 🎮 Usage

Open your terminal (or Git Bash), then run:
### Rent a Vehicle:
- Click on `Rent Vehicle`
- Select a vehicle
- Enter your **Name** and **Contact Number**
- You’ll get a unique rental ID like `RC3`

```bash
git clone https://github.com/Zen0n111/vehicle-rental-system.git
````

>
### Return a Vehicle:
- Click on `Return Vehicle`
- Enter your **Rental ID** (e.g., `RM5`)
- Vehicle will be returned and added back to availability

---

### 📂 2. Navigate into the Project Folder
## Validation

```bash
cd vehicle-rental-system
```
- Contact number must be numeric and 10 digits
- Name field cannot be empty
- Rental ID format is validated during return

---

### 💻 3. Open the Project in VS Code

If you have VS Code installed and added to PATH, run:

```bash
code .
```
## 📌 Notes

This will open the whole project in VS Code.
- No database integration; data is stored in memory using ArrayLists.
- Data is reset every time the application restarts.
- You can add more sample vehicles in `DataStore` for testing.

---

### ☕ 4. Make Sure Java is Installed
## 📧 Contact

Ensure that you have Java JDK installed and set up. You can verify it by running:
For improvements or questions, feel free to reach out!

```bash
java -version
```
- gptdevansh@gmail.com

and

```bash
javac -version
```

---

### ▶️ 5. Run the Program

1. Open the `Main.java` file (located in `ui/` or root, depending on your structure).
2. Click the **Run** ▶️ button at the top right, or right-click and select **Run Java**.
3. If you’re using Swing, the UI window should appear.
- https://www.linkedin.com/in/gptdevansh

---

### ✅ You're All Set!

You’re now ready to build and test the Vehicle Rental System project in VS Code. 🚗💻

11 changes: 11 additions & 0 deletions Vehicle-Rental-System.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
42 changes: 42 additions & 0 deletions src/VehicleRentalSystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import models.Car;
import models.Motorcycle;
import system.*;
import ui.MainMenuUI;

public class VehicleRentalSystem {
public static void main(String[] args) {

DataStore dataStore = new DataStore();
RentalSystem rentalSystem = new RentalSystem(dataStore);

// Sample data - 25 Vehicles
dataStore.addVehicle(new Car("C001", "Toyota", "Corolla", 5, 4));
dataStore.addVehicle(new Motorcycle("M001", "Honda", "Shine", true, 2));
dataStore.addVehicle(new Car("C002", "Hyundai", "i20", 5, 4));
dataStore.addVehicle(new Motorcycle("M002", "Yamaha", "FZ", false, 2));
dataStore.addVehicle(new Car("C003", "Maruti", "Swift", 5, 4));
dataStore.addVehicle(new Motorcycle("M003", "Royal Enfield", "Classic 350", false, 2));
dataStore.addVehicle(new Car("C004", "Kia", "Seltos", 5, 5));
dataStore.addVehicle(new Motorcycle("M004", "TVS", "Apache RTR 160", false, 2));
dataStore.addVehicle(new Car("C005", "Tata", "Altroz", 5, 5));
dataStore.addVehicle(new Motorcycle("M005", "Bajaj", "Pulsar 150", false, 2));
dataStore.addVehicle(new Car("C006", "Honda", "City", 5, 5));
dataStore.addVehicle(new Motorcycle("M006", "Suzuki", "Access 125", true, 2));
dataStore.addVehicle(new Car("C007", "Ford", "Ecosport", 5, 5));
dataStore.addVehicle(new Motorcycle("M007", "Hero", "Splendor Plus", true, 2));
dataStore.addVehicle(new Car("C008", "Skoda", "Rapid", 5, 5));
dataStore.addVehicle(new Motorcycle("M008", "KTM", "Duke 200", false, 2));
dataStore.addVehicle(new Car("C009", "Volkswagen", "Polo", 5, 4));
dataStore.addVehicle(new Motorcycle("M009", "Benelli", "Imperiale 400", false, 2));
dataStore.addVehicle(new Car("C010", "MG", "Astor", 5, 5));
dataStore.addVehicle(new Motorcycle("M010", "Harley-Davidson", "Street 750", false, 2));
dataStore.addVehicle(new Car("C011", "Mahindra", "XUV300", 5, 5));
dataStore.addVehicle(new Car("C012", "Renault", "Kiger", 5, 5));
dataStore.addVehicle(new Motorcycle("M011", "BMW", "G310R", false, 2));
dataStore.addVehicle(new Car("C013", "Jeep", "Compass", 5, 5));
dataStore.addVehicle(new Motorcycle("M012", "Aprilia", "SR 160", true, 2));

// Launch GUI
javax.swing.SwingUtilities.invokeLater(() -> new MainMenuUI(rentalSystem));
}
}
44 changes: 42 additions & 2 deletions src/models/Car.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
package models;

/**
* Represents a Car vehicle, extending the generic Vehicle class.
* Adds specific attribute: seating capacity.
*/
public class Car extends Vehicle {
// Car subclass
}

private final int seatingCapacity;

/**
* Constructs a Car with given details.
*
* @param id Unique identifier for the car
* @param brand Brand name of the car
* @param model Model name of the car
* @param seatingCapacity Number of seats in the car
* @param quantity Number of such cars available
*/
public Car(String id, String brand, String model, int seatingCapacity, int quantity) {
super(id, brand, model, quantity);
this.seatingCapacity = seatingCapacity;
}

/**
* Returns the type of vehicle.
* @return "Car"
*/
@Override
public String getType() {
return "Car";
}

public int getSeatingCapacity() {
return seatingCapacity;
}

/**
* Provides a string representation of the car, including base info and seating.
*/
@Override
public String toString() {
return super.toString() + " : " + seatingCapacity + "-seats capacity";
}

}
59 changes: 57 additions & 2 deletions src/models/Customer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,61 @@
package models;

/**
* Represents a Customer who rents a Vehicle.
* Stores customer's name, contact number, and the rented vehicle.
*/
public class Customer {
// Customer class
}
private String name;
private String contactNumber;
private Vehicle rentedVehicle;

/**
* Constructs a Customer with provided details and rented vehicle.
*
* @param name Customer's full name
* @param contactNumber Customer's contact number
* @param selectedVehicle Vehicle rented by the customer
*/
public Customer(String name, String contactNumber, Vehicle selectedVehicle) {
this.name = name;
this.contactNumber = contactNumber;
this.rentedVehicle = selectedVehicle;
}

// Getters and setters for encapsulation

public Vehicle getRentedVehicle() {
return rentedVehicle;
}

public void setRentedVehicle(Vehicle rentedVehicle) {
this.rentedVehicle = rentedVehicle;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getContactNumber() {
return contactNumber;
}

public void setContactNumber(String contactNumber) {
this.contactNumber = contactNumber;
}

/**
* Returns string representation of customer (excluding vehicle info).
*/
@Override
public String toString() {
return "Customer{" +
"name='" + name + '\'' +
", contactNumber='" + contactNumber + '\'' +
'}';
}
}
46 changes: 44 additions & 2 deletions src/models/Motorcycle.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,48 @@
package models;

/**
* Represents a Motorcycle, extending the generic Vehicle class.
* Adds a specific attribute indicating if the motorcycle has a carrier.
*/
public class Motorcycle extends Vehicle {
// Motorcycle subclass
}

private final boolean hasCarrier;

/**
* Constructs a Motorcycle with given details.
*
* @param id Unique identifier for the motorcycle
* @param brand Brand name of the motorcycle
* @param model Model name of the motorcycle
* @param hasCarrier Whether the motorcycle has a carrier attachment
* @param quantity Number of such motorcycles available
*/
public Motorcycle(String id, String brand, String model, boolean hasCarrier, int quantity) {
super(id, brand, model, quantity);
this.hasCarrier = hasCarrier;
}

/**
* Returns the type of vehicle.
* @return "Motorcycle"
*/
@Override
public String getType() {
return "Motorcycle";
}

/**
* Returns whether this motorcycle has a carrier.
*/
public boolean hasCarrier() {
return hasCarrier;
}

/**
* Returns string representation including base info and carrier info.
*/
@Override
public String toString() {
return super.toString() + " : " + (hasCarrier ? "Has-Carrier" : "No-Carrier");
}
}
Loading