Car rental management system Using C++ With Source Code

Introduction :

In this project, we have implemented a Car Rental System using C++ programming language. This system allows users to manage various aspects of a car rental service, such as adding, updating, and removing cars from the rental records. Additionally, it handles renting activities, including listing available cars, checking car details, renting cars, and modifying rental records. The system stores the data in JSON format, utilizing the JsonCpp library for manipulating these values.

Whether you’re looking to automate basic operations or store large amounts of data, this system can help streamline the day-to-day activities of a car rental business.

Features

Here are the key features of the Car Rental System:

  • Add Car: This function allows users to add new cars to the system. Each car requires the input of several details, including the car model, brand, and unique car ID.

  • Update Car Details: This feature enables users to update existing car information. If any changes are made to a car’s details, such as its availability or specifications, these updates are reflected in the system.

  • Remove Car: Users can remove a car from the records. Since this operation clears data permanently, caution is advised when performing this task.

  • List All Cars: This function displays all available cars in the car rental system, allowing users to browse through the entire inventory.

  • Check Car: Provides details about a specific car, including its availability status, ID, and associated rent records.

  • Rent a Car: Users can rent a car, which records the renter’s name, car number, rental ID, and rent price.

  • Modify Rent Records: This feature allows users to update existing rental records. For instance, if the rent price changes, this can be modified in the system.

System Design

The Car Rental System uses a modular design to manage car and rent records. Data is stored in JSON format in two files:

  1. cars.json - Stores details of the available cars.
  2. rents.json - Stores details of the rental records.

This ensures that all car and rental data are well-organized and easily accessible. The JsonCpp library facilitates seamless interaction with these JSON files.

How to Run the Code:

  1. Download the Project: Extract the files from the provided source code zip file.
  2. Install Dependencies: Ensure that the JsonCpp library is installed on your system.
  3. Compile the Code: Use the following command to compile the main code along with the JsonCpp library.
  4. g++ main.cpp jsoncpp.cpp -o car_rental_system
    
  5. Run the Executable: After successful compilation, run the program using the following command:
  6. ./car_rental_system
    

Code Explanation :

Here’s a breakdown of the core parts of the code:

  • main.cpp: This is the main driver of the program, which handles user input and controls the flow of the program. It interacts with both the cars.json and rents.json files to manage car and rent records.

  • jsoncpp.cpp: This file handles all interactions with the JSON data. It uses the JsonCpp library to read from and write to the JSON files.

Source Code :

main.cpp

				
					#include
#include
#include
#include 
#include
#include "Customer.h"
#include "Vehicle.h"
#include "Reservation.h"
#include
using namespace sqlite_orm;

/**
* CUSTOMER CLASS FUNCTIONS
* ----------------------------------------------------------------------
* Functions to create, delete and display customers.
*/
template 
void Customer::createCustomer(T storage) {
	std::string userInputStr;

	//Entry explanation
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(28) << "CREATING A NEW CUSTOMER" << std::right << std::setfill(' ') << std::setw(16) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;

	//Sections
	std::cout << "|_" << std::right << std::setfill(' ') << std::setw(32) << "1. CUSTOMER GENERAL INFORMATION" << std::right << std::setfill(' ') << std::setw(13) << "_ | " << std::endl << std::endl;

	std::cout <> this->name;

	std::cout <> this->surname;

	std::cout <> this->dateOfBirth;
	std::cout << std::endl;

	std::cout << "|_" << std::right << std::setfill(' ') << std::setw(20) << "2. CUSTOMER ADDRESS" << std::right << std::setfill(' ') << std::setw(25) << "_ | " << std::endl << std::endl;

	std::cout <> userInputStr;
	this->address.setCountry(userInputStr);

	std::cout <> userInputStr;
	this->address.setCity(userInputStr);

	std::cout <> userInputStr;
	this->address.setPostalCode(userInputStr);

	std::cout <address.setStreet(userInputStr);
	std::cout << std::endl;

	std::cout << "|_" << std::right << std::setfill(' ') << std::setw(23) << "3. CONTACT INFORMATION" << std::right << std::setfill(' ') << std::setw(22) << "_ | " << std::endl << std::endl;

	std::cout <> this->phoneNumber;

	std::cout <> this->email;
	std::cout << std::endl;

	std::cout << "|_" << std::right << std::setfill(' ') << std::setw(27) << "4. CREDIT CARD INFORMATION" << std::right << std::setfill(' ') << std::setw(18) << "_ | " << std::endl << std::endl;

	std::cout <> userInputStr;
	this->creditCard.setCardNumber(userInputStr);

	std::cout <> userInputStr;
	this->creditCard.setExpiryDate(userInputStr);
	std::cout << std::endl;

	std::cout <> userInputStr;
	this->creditCard.setCvv(userInputStr);


	storage.insert(*this);

	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(34) << "CUSTOMER CREATED SUCESSFULLY!" << std::right << std::setfill(' ') << std::setw(10) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
}

template 
void Customer::deleteCustomer(T storage) {
	//Entry explanation
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(28) << "DELETE CUSTOMER" << std::right << std::setfill(' ') << std::setw(16) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;

	std::cout <> this->idCustomer;

	//If user deleted delete reservations
	storage.remove_all(where(c(&Reservation::getIdCustomer) == this->idCustomer));

	storage.remove(idCustomer);

	std::cout << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(30) << "CUSTOMER DELETED" << std::right << std::setfill(' ') << std::setw(13) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
} 

template 
static void Customer::displayCustomers(T storage) {
	auto rows = storage.select(
		columns(&Customer::getIdCustomer, &Customer::getName, &Customer::getSurname,
			        &Customer::getDateOfBirth, &Customer::getCountry, &Customer::getCity, 
					&Customer::getPostalCode, &Customer::getStreet, &Customer::getPhoneNumber, 
					&Customer::getEmail, &Customer::getCreditCardNumber, 
					&Customer::getCreditCardExpiryDate, &Customer::getCreditCardCvv));

	//Entry explanation
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(28) << "CUSTOMER LIST" 
				<< std::right << std::setfill(' ') << std::setw(16) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;

	std::cout << std::setfill('_') << std::setw(199) << std::left << " _" << "_" << std::endl
				<<" | " << std::setfill(' ') << std::setw(3) << std::left << "ID"
				 << " | " << std::setw(10) << "Name"
				 << " | " << std::setw(10) << "Surname"
				 << " | " << std::setw(11) << "D.O.B."
				 << " | " << std::setw(10) << "Country"
				 << " | " << std::setw(10) << "City"
				 << " | " << std::setw(11) << "Postal Code"
				 << " | " << std::setw(20) << "Street"
				 << " | " << std::setw(11) << "Phone No."
				 << " | " << std::setw(30) << "Email"
				 << " | " << std::setw(16) << "CC Number"
				 << " | " << std::setw(10) << "CC D.O.E."
				 << " | " << std::setw(7) << "CC CVV"
				 << " | " << std::endl
				 << std::setfill('-') << std::setw(199) << std::left << " |" << "|" << std::endl;
	for (auto& row : rows) {
		std::cout << " | " << std::setfill(' ') << std::setw(3) << std::left << std::get(row)
					<< " | " << std::setw(10) << std::get(row)
					<< " | " << std::setw(10) << std::get(row)
					<< " | " << std::setw(11) << std::get(row)
					<< " | " << std::setw(10) << std::get(row)
					<< " | " << std::setw(10) << std::get(row)
					<< " | " << std::setw(11) << std::get(row)
					<< " | " << std::setw(20) << std::get(row)
					<< " | " << std::setw(11) << std::get(row)
					<< " | " << std::setw(30) << std::get(row)
					<< " | " << std::setw(16) << std::get(row)
					<< " | " << std::setw(10) << std::get(row)
					<< " | " << std::setw(7) << std::get(row)
					<< " | " << std::endl;
	}
	std::cout << std::setfill('_') << std::setw(199) << std::left << " |" << "|" << std::endl;
}

/**
* VEHICLE CLASS FUNCTIONS
* ----------------------------------------------------------------------
* Functions to add, delete and display vehicles.
*/
template 
void Vehicle::addVehicle(T storage) {
	std::string userInputStr;

	//Entry explanation
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(28) << "ADDING A NEW VEHICLE" << std::right << std::setfill(' ') << std::setw(16) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;

	// Sections
	std::cout << "|_" << std::right << std::setfill(' ') << std::setw(32) << "1. VEHICLE GENERAL INFORMATION" << std::right << std::setfill(' ') << std::setw(13) << "_ | " << std::endl << std::endl;

	std::cout <> this->model;

	std::cout <make = userInputStr;

	std::cout <> this->manufactoringYear;
	std::cout << std::endl;

	std::cout << "|_" << std::right << std::setfill(' ') << std::setw(32) << "1. VEHICLE ADDITIONAL INFORMATION" << std::right << std::setfill(' ') << std::setw(13) << "_ | " << std::endl << std::endl;

	userInputStr = "\0";
	while (userInputStr != "1" && userInputStr != "2") {
		std::cout << " Vehicle Transmission Types: " << std::endl;
		std::cout << " [1] - Manual transmisson" << std::endl;
		std::cout << " [2] - Automatic transmisson" << std::endl;
		std::cout <> userInputStr;
		if (userInputStr == "1") {
			this->transmissonType = "manual";
			break;
		}
		else if (userInputStr == "2") {
			this->transmissonType = "automatic";
			break;
		}
		std::cout << " [Error] Please, select the right type of transmission. " << std::endl << std::endl;
	}
	std::cout << std::endl;

	std::cout <> this->passengerCapacity;
	std::cout << std::endl;

	std::cout <> this->ratePerDay;
	std::cout << std::endl;

	storage.insert(*this);

	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(34) << "VEHICLE ADDED SUCESSFULLY!" << std::right << std::setfill(' ') << std::setw(10) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
}

template 
void Vehicle::deleteVehicle(T storage) {
	//Entry explanation
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(28) << "DELETE VEHICLE" << std::right << std::setfill(' ') << std::setw(16) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;

	std::cout <> this->idVehicle;

	//If vehicle deleted delete reservations
	storage.remove_all(where(c(&Reservation::getIdVehicle) == this->idVehicle));

	storage.remove(idVehicle);

	std::cout << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(30) << "VEHICLE DELETED" << std::right << std::setfill(' ') << std::setw(13) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
}

template 
static void Vehicle::displayVehicles(T storage) {
	auto rows = storage.select(
		columns(&Vehicle::getIdVehicle, &Vehicle::getModel, &Vehicle::getMake,
					&Vehicle::getManufactoringYear, &Vehicle::getPassengerCapacity, &Vehicle::getTransmissionType,
					&Vehicle::getRatePerDay, &Vehicle::getStatusVehicle));

	//Entry explanation
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(28) << "VEHICLES LIST"
		<< std::right << std::setfill(' ') << std::setw(16) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;

	std::cout << std::setfill('_') << std::setw(98) << std::left << " _" << "_" << std::endl
		<< " | " << std::setfill(' ') << std::setw(3) << std::left << "ID"
		<< " | " << std::setw(10) << "Model"
		<< " | " << std::setw(10) << "Make"
		<< " | " << std::setw(5) << "Year"
		<< " | " << std::setw(11) << "Passengers"
		<< " | " << std::setw(13) << "Transmission"
		<< " | " << std::setw(10) << "EUR / Day"
		<< " | " << std::setw(11) << "Status"
		<< " | " << std::endl
		<< std::setfill('-') << std::setw(98) << std::left << " |" << "|" << std::endl;
	for (auto& row : rows) {
		std::cout << " | " << std::setfill(' ') << std::setw(3) << std::left << std::get(row)
			<< " | " << std::setw(10) << std::get(row)
			<< " | " << std::setw(10) << std::get(row)
			<< " | " << std::setw(5) << std::get(row)
			<< " | " << std::setw(11) << std::get(row)
			<< " | " << std::setw(13) << std::get(row)
			<< " | " << std::setw(10) << std::get(row)
			<< " | " << std::setw(11) << std::get(row)
			<< " | " << std::endl;
	}
	std::cout << std::setfill('_') << std::setw(98) << std::left << " |" << "|" << std::endl;
}

/**
* RESERVATION CLASS FUNCTIONS
* ----------------------------------------------------------------------
* Functions to make, cancel and display reservation.
*/
template 
void Reservation::makeReservation(T storage) {
	std::string userInputStr;
	int userInputNum;

	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(28) << "MAKE A RESERVATION" << std::right << std::setfill(' ') << std::setw(16) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << std::endl;

	std::cout <> userInputNum;
	this->customer.setIdCustomer(userInputNum);

	std::cout <> userInputNum;

	auto vehicle = storage.get(userInputNum);
	this->vehicle = vehicle;

	//Change vehicle status
	Vehicle tmpVehicle;
	tmpVehicle = vehicle;
	tmpVehicle.setStatusVehicle("reserved");
	storage.replace(tmpVehicle);
	
	std::cout <> rentDays;
	std::cout <setTransactionValue(this->vehicle.getRatePerDay() * rentDays);
	storage.insert(*this);

	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(30) << "RESERVATION COMPLETED" << std::right << std::setfill(' ') << std::setw(13) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
}

template 
void Reservation::cancelReservation(T storage) {
	//Entry explanation
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(28) << "CANCEL RESERVATION" << std::right << std::setfill(' ') << std::setw(16) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;

	int userInputNum;
	std::cout <> userInputNum;
	
	auto reservation = storage.get(userInputNum);

	*this = reservation;
	this->status = "canceled";

	//Change vehicle status
	auto vehicle = storage.get(this->vehicle.getIdVehicle());
	Vehicle tmpVehicle;
	tmpVehicle = vehicle;
	tmpVehicle.setStatusVehicle("available");
	storage.replace(tmpVehicle);

	storage.update(*this);

	std::cout << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(30) << "RESERVATION CANCELED" << std::right << std::setfill(' ') << std::setw(13) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
}

template 
static void Reservation::displayReservations(T storage) {
	auto rows = storage.select(
		columns(&Reservation::getIdReservation, &Customer::getName, &Vehicle::getModel,
					&Vehicle::getMake, &Reservation::getRentDays, &Reservation::getTransactionValue, &Reservation::getStatus),
		natural_join(),
		natural_join(),
		where(c(&Customer::getIdCustomer) == &Reservation::getIdCustomer and c(&Vehicle::getIdVehicle) == &Reservation::getIdVehicle)
	);

	//Entry explanation
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;
	std::cout << "|_ " << std::right << std::setfill(' ') << std::setw(28) << "RESERVATIONS LIST"
				<< std::right << std::setfill(' ') << std::setw(16) << "_ | " << std::endl;
	std::cout << "|_" << std::right << std::setfill('*') << std::setw(45) << "_ | " << std::endl;

	std::cout << std::setfill('_') << std::setw(101) << std::left << " _" << "_" << std::endl
		<< " | " << std::setfill(' ') << std::setw(3) << std::left << "ID"
		<< " | " << std::setw(15) << "Customer Name"
		<< " | " << std::setw(15) << "Vehicle Model"
		<< " | " << std::setw(15) << "Vehicle Make"
		<< " | " << std::setw(11) << "Rent Days"
		<< " | " << std::setw(12) << "Paid (EUR)"
		<< " | " << std::setw(8) << "Status"
		<< " | " << std::endl
		<< std::setfill('-') << std::setw(101) << std::left << " |" << "|" << std::endl;

	for (auto& row : rows) {
		
		std::cout << " | " << std::setfill(' ') << std::setw(3) << std::left << std::get(row)
			<< " | " << std::setw(15) << std::get(row)
			<< " | " << std::setw(15) << std::get(row)
			<< " | " << std::setw(15) << std::get(row)
			<< " | " << std::setw(11) << std::get(row)
			<< " | " << std::setw(12) << std::get(row)
			<< " | " << std::setw(8) << std::get(row)
			<< " | " << std::endl;
	}
	std::cout << std::setfill('_') << std::setw(101) << std::left << " |" << "|" << std::endl;
}

template 
void manageCustomers(T storage) {
	Customer customer;
	int menuItem;

	do {
		std::cout << std::endl;
		customer.displayCustomers(storage);
		std::cout << std::endl;
		std::cout << "===================================" << std::endl;
		std::cout << "||                               ||" << std::endl;
		std::cout << "||     CAR RENTAL SYSTEM 2022    ||" << std::endl;
		std::cout << "||                               ||" << std::endl;
		std::cout << "===================================" << std::endl;
		std::cout << "        CUSTOMERS SUB MENU                                   " << std::endl;
		std::cout << "-----------------------------------" << std::endl;
		std::cout << "||   1 - Add Customer            ||" << std::endl;
		std::cout << "||   2 - Terminate Customer      ||" << std::endl;
		std::cout << "||   0 - Back to MAIN MENU       ||" << std::endl;
		std::cout << "-----------------------------------" << std::endl;
		std::cout <> menuItem;
		std::cout << "-----------------------------------" << std::endl;
		std::cout << std::endl << std::endl;

		switch (menuItem) {
		case 1:
			customer.createCustomer(storage);
			break;
		case 2:
			customer.deleteCustomer(storage);
			break;
		default:
			continue;
		}
		std::system("cls");
	} while (menuItem != 0);
}

template 
void manageVehicles(T storage) {
	Vehicle vehicle;
	int menuItem;
	do {
		std::cout << std::endl;
		vehicle.displayVehicles(storage);
		std::cout << std::endl;
		std::cout << "===================================" << std::endl;
		std::cout << "||                               ||" << std::endl;
		std::cout << "||     CAR RENTAL SYSTEM 2022    ||" << std::endl;
		std::cout << "||                               ||" << std::endl;
		std::cout << "===================================" << std::endl;
		std::cout << "          VEHICLES SUB MENU                                   " << std::endl;
		std::cout << "-----------------------------------" << std::endl;
		std::cout << "||   1 - Add Vehicle              ||" << std::endl;
		std::cout << "||   2 - Delete Vehicle           ||" << std::endl;
		std::cout << "||   0 - Back to MAIN MENU        ||" << std::endl;
		std::cout << "-----------------------------------" << std::endl;
		std::cout <> menuItem;
		std::cout << "-----------------------------------" << std::endl;
		std::cout << std::endl << std::endl;

		switch (menuItem) {
		case 1:
			vehicle.addVehicle(storage);
			break;
		case 2:
			vehicle.deleteVehicle(storage);
			break;
		default:
			continue;
		}
		std::system("cls");
	} while (menuItem != 0);
}

template 
void manageReservations(T storage) {
	Customer customer;
	Vehicle vehicle;
	Reservation reservation;
	int menuItem;
	do {
		std::cout << std::endl;
		reservation.displayReservations(storage);
		std::cout << std::endl;
		std::cout << "===================================" << std::endl;
		std::cout << "||                               ||" << std::endl;
		std::cout << "||     CAR RENTAL SYSTEM 2022    ||" << std::endl;
		std::cout << "||                               ||" << std::endl;
		std::cout << "===================================" << std::endl;
		std::cout << "          VEHICLES SUB MENU                                   " << std::endl;
		std::cout << "-----------------------------------" << std::endl;
		std::cout << "||   1 - Make a reservation       ||" << std::endl;
		std::cout << "||   2 - Cancel Reservation       ||" << std::endl;
		std::cout << "||   0 - Back to MAIN MENU        ||" << std::endl;
		std::cout << "-----------------------------------" << std::endl;
		std::cout <> menuItem;
		std::cout << "-----------------------------------" << std::endl;
		std::cout << std::endl << std::endl;

		switch (menuItem) {
		case 1:
			std::cout << std::endl << std::endl;
			customer.displayCustomers(storage);
			std::cout << std::endl << std::endl;
			vehicle.displayVehicles(storage);
			std::cout << std::endl << std::endl;
			reservation.makeReservation(storage);
			break;
		case 2:
			reservation.cancelReservation(storage);
			break;
		default:
			continue;
		}
		std::system("cls");
	} while (menuItem != 0);
}

template 
void showAllLists(T storage) {
	Customer customer;
	Vehicle vehicle;
	Reservation reservation;

	std::cout << std::endl;
	customer.displayCustomers(storage);
	vehicle.displayVehicles(storage);
	reservation.displayReservations(storage);
	
	std::cout << std::endl;
	std::system("pause");
}

template 
void initializeApp(T storage) {
	SetConsoleTitleA("Car Rental System");

	int menuItem;
	do {
		std::cout << "===================================" << std::endl;
		std::cout << "||                               ||" << std::endl;
		std::cout << "||     CAR RENTAL SYSTEM 2022    ||" << std::endl;
		std::cout << "||                               ||" << std::endl;
		std::cout << "===================================" << std::endl;
		std::cout << "             MAIN MENU                                   " << std::endl;
		std::cout << "-----------------------------------" << std::endl;
		std::cout << "||   1 - Manage Customers        ||" << std::endl;
		std::cout << "||   2 - Manage Vehicles         ||" << std::endl;
		std::cout << "||   3 - Manage Reservations     ||" << std::endl;
		std::cout << "||   4 - Show All Databases      ||" << std::endl;
		std::cout << "||   0 - Exit                    ||" << std::endl;
		std::cout << "-----------------------------------" << std::endl;
		std::cout <> menuItem;
		std::cout << "-----------------------------------" << std::endl;
		std::cout << std::endl << std::endl;

		switch (menuItem) {
		case 1: 
			std::system("cls");
			manageCustomers(storage);
			break;
		case 2: 
			std::system("cls");
			manageVehicles(storage);
			break;
		case 3:
			std::system("cls");
			manageReservations(storage);
			break;
		case 4:
			std::system("cls");
			showAllLists(storage);
			break;
		default:
			continue;
		}
		std::system("cls");
	} while (menuItem !=  0);

}

int main() {
	/**
	* SQLITE ORM WRAPPER STORAGE (DATABASE)
	* ----------------------------------------------------------------------
	* Create tables and columns. If a column is edited,
	* the whole table will be dropped.
	*/
	auto storage = make_storage("storage",
		make_table("Customer",
			make_column("idCustomer", &Customer::setIdCustomer,	&Customer::getIdCustomer,	autoincrement(),	primary_key()),
			make_column("name",	&Customer::setName,	&Customer::getName),
			make_column("surname",	&Customer::setSurname, &Customer::getSurname),
			make_column("dateOfBirth", &Customer::setDateOfBirth, &Customer::getDateOfBirth),
			make_column("country",	&Customer::setCountry,	&Customer::getCountry),
			make_column("city", 	&Customer::setCity, 	&Customer::getCity),
			make_column("postalCode",	&Customer::setPostalCode,	&Customer::getPostalCode),
			make_column("street", &Customer::setStreet,	&Customer::getStreet),
			make_column("phoneNumber",	&Customer::setPhoneNumber, &Customer::getPhoneNumber),
			make_column("email",	&Customer::setEmail, &Customer::getEmail),
			make_column("cardNumber", &Customer::setCreditCardNumber, &Customer::getCreditCardNumber),
			make_column("cardExpiryDate", &Customer::setCreditCardExpiryDate,	&Customer::getCreditCardExpiryDate),
			make_column("cardCvv",	&Customer::setCreditCardCvv, &Customer::getCreditCardCvv)
		), make_table(	"Vehicle",
			make_column("idVehicle",	&Vehicle::setIdVehicle, &Vehicle::getIdVehicle,	autoincrement(),	primary_key()),
			make_column("model", &Vehicle::setModel,	&Vehicle::getModel),
			make_column("make",	&Vehicle::setMake, &Vehicle::getMake),
			make_column("manufactoringYear", &Vehicle::setManufactoringYear,	&Vehicle::getManufactoringYear),
			make_column("transmissionType",	&Vehicle::setTransmissionType,	&Vehicle::getTransmissionType),
			make_column("passengerCapacity", &Vehicle::setPassengerCapacity,	&Vehicle::getPassengerCapacity),
			make_column("ratePerDay",	&Vehicle::setRatePerDay, 	&Vehicle::getRatePerDay),
			make_column("statusVehicle", &Vehicle::setStatusVehicle, &Vehicle::getStatusVehicle)
		), make_table(	"Reservation",
			make_column("idReservation", &Reservation::setIdReservation, &Reservation::getIdReservation,	autoincrement(), primary_key()),
			make_column("idCustomer", &Reservation::setIdCustomer, &Reservation::getIdCustomer),
			make_column("idVehicle", &Reservation::setIdVehicle, &Reservation::getIdVehicle),
			make_column("transactionValue", &Reservation::setTransactionValue, &Reservation::getTransactionValue),
			make_column("rentDays", &Reservation::setRentDays, &Reservation::getRentDays),
			make_column("statusReservation", &Reservation::setStatus, &Reservation::getStatus)));
	storage.sync_schema();

	/**
	* START APPLICATION
	*/
	initializeApp(storage);

	return 0;
}
				
			

Address.cpp

				
					#include "Address.h"

Address::Address() {
	street = "uninitialized";
	postalCode = "uninitialized";
	country = "uninitialized";
}

Address::Address(std::string street, std::string postalCode, std::string city, std::string country) 
	: street(street), postalCode(postalCode), city(city), country(country) {}

Address::~Address() {}

void Address::setStreet(std::string street) { this->street = street; }
void Address::setPostalCode(std::string postalCode) { this->postalCode = postalCode; }
void Address::setCity(std::string city) { this->city = city; }
void Address::setCountry(std::string country) { this->country = country; }

std::string Address::getStreet() const { return this->street; }
std::string Address::getPostalCode() const { return this->postalCode; }
std::string Address::getCity() const { return this->city; }
std::string Address::getCountry() const { return this->country; }
				
			

CreditCard.cpp

				
					#include "CreditCard.h"

CreditCard::CreditCard() {
	cardNumber = "uninitialized";
	cvv = "uninitialized";
	expiryDate = "uninitialized";
}

CreditCard::CreditCard(std::string cardNumber, std::string cvv, std::string expiryDate)
	: cardNumber(cardNumber), cvv(cvv), expiryDate(expiryDate) {}

CreditCard::~CreditCard() {}

void CreditCard::setCardNumber(std::string cardNumber) { this->cardNumber = cardNumber; }
void CreditCard::setExpiryDate(std::string expiryDate) { this->expiryDate = expiryDate; }
void CreditCard::setCvv(std::string cvv) { this->cvv = cvv; }

std::string CreditCard::getCardNumber() const { return this->cardNumber; }
std::string CreditCard::getExpiryDate() const { return this->expiryDate; }
std::string CreditCard::getCvv() const { return this->cvv; }
				
			

Customer.cpp

				
					#include "Customer.h"

Customer::Customer() {
	idCustomer = -1;
	name = "uninitialized";
	surname = "uninitialized";
	phoneNumber = "uninitialized";
	email = "uninitialized";
}

Customer::Customer(std::string name, std::string surname, std::string dateOfBirth, std::string phoneNumber, std::string email, std::string street, std::string postalCode, std::string city, std::string country, std::string cardNumber, std::string cvv, std::string ccDate)
							: name(name), surname(surname),  dateOfBirth(dateOfBirth),  phoneNumber(phoneNumber), email(email),  address(street, postalCode, city, country ),  creditCard(cardNumber, cvv, ccDate) {
	idCustomer = -1;
}

Customer::~Customer() {}

void Customer::setIdCustomer(int idCustomer) { this->idCustomer = idCustomer; }
void Customer::setName(std::string name) { this->name = name; }
void Customer::setSurname(std::string surname) { this->surname = surname; }
void Customer::setPhoneNumber(std::string phoneNumber) { this->phoneNumber = phoneNumber; }
void Customer::setEmail(std::string email) { this->email = email; }
void Customer::setDateOfBirth(std::string dateOfBirth) { this->dateOfBirth = dateOfBirth; }

int Customer::getIdCustomer() const { return this->idCustomer; }
std::string Customer::getName() const { return this->name; }
std::string Customer::getSurname() const { return this->surname; }
std::string Customer::getPhoneNumber() const { return this->phoneNumber; }
std::string Customer::getEmail() const { return this->email; }
std::string Customer::getDateOfBirth() const { return dateOfBirth; }

void Customer::setCreditCardNumber(std::string cardNumber) { this->creditCard.setCardNumber(cardNumber); }
void Customer::setCreditCardCvv(std::string cvv) { this->creditCard.setCvv(cvv); }
void Customer::setCreditCardExpiryDate(std::string expiryDate) { this->creditCard.setExpiryDate(expiryDate); }

std::string Customer::getCreditCardNumber() const { return this->creditCard.getCardNumber(); }
std::string Customer::getCreditCardCvv() const { return this->creditCard.getCvv(); }
std::string Customer::getCreditCardExpiryDate() const { return this->creditCard.getExpiryDate(); }

void Customer::setStreet(std::string street) { this->address.setStreet(street); }
void Customer::setPostalCode(std::string postalCode) { this->address.setPostalCode(postalCode); }
void Customer::setCity(std::string city) { this->address.setCity(city); }
void Customer::setCountry(std::string country) { this->address.setCountry(country); }

std::string Customer::getStreet() const { return this->address.getStreet(); }
std::string Customer::getPostalCode() const { return this->address.getPostalCode(); }
std::string Customer::getCity() const { return this->address.getCity(); }
std::string Customer::getCountry() const { return this->address.getCountry(); }
				
			

Reservation.cpp

				
					#include "Reservation.h"

Reservation::Reservation() {
	idReservation = -1;
	transactionValue = -1;
	rentDays = 0;
	status = "active";
}

Reservation::Reservation(int idCustomer, int idVehicle, int transactionValue, int rentDays)
								  :transactionValue(transactionValue), rentDays(rentDays) {
	idReservation = -1;
	status = "active";
	this->customer.setIdCustomer(idCustomer);
	this->vehicle.setIdVehicle(idVehicle);
}

Reservation::~Reservation() {}

void Reservation::setIdReservation(int idReservation) { this->idReservation = idReservation; }
void Reservation::setIdVehicle(int idVehicle) { this->vehicle.setIdVehicle(idVehicle); }
void Reservation::setIdCustomer(int idCustomer) { this->customer.setIdCustomer(idCustomer); }
void Reservation::setTransactionValue(double transactionValue) { this->transactionValue = transactionValue; }
void Reservation::setRentDays(int rentDays) { this->rentDays = rentDays; }
void Reservation::setStatus(std::string status) { this->status = status; }

int Reservation::getIdReservation() const { return this->idReservation; }
int Reservation::getIdVehicle() const { return this->vehicle.getIdVehicle(); }
int Reservation::getIdCustomer() const { return this->customer.getIdCustomer(); }
double Reservation::getTransactionValue() const { return this->transactionValue; }
int Reservation::getRentDays() const { return this->rentDays; }
std::string Reservation::getStatus() const { return this->status; }
				
			

Vehicle.cpp

				
					#include "Vehicle.h"

Vehicle::Vehicle() {
	idVehicle = -1;
	make = "uninitialized";
	model = "uninitialized";
	manufactoringYear = -1;
	passengerCapacity = -1;
	transmissonType = "uninitialized";
	ratePerDay = -1;
	statusVehicle = "available";
}

Vehicle::Vehicle(std::string make, std::string model, std::string  transmissionType, int manufactoringYear, int passengerCapacity, double ratePerDay)
					: make(make), model(model), transmissonType(transmissonType), manufactoringYear(manufactoringYear), passengerCapacity(passengerCapacity), ratePerDay(ratePerDay) {
	idVehicle = -1;
	statusVehicle = "available";
}

Vehicle::~Vehicle() {}

void Vehicle::setIdVehicle(int idVehicle) { this->idVehicle = idVehicle; }
void Vehicle::setMake(std::string make) { this->make = make; }
void Vehicle::setModel(std::string model) { this->model = model; }
void Vehicle::setTransmissionType(std::string transmissionType) { this->transmissonType = transmissionType; }
void Vehicle::setManufactoringYear(int manufactoringYear) { this->manufactoringYear = manufactoringYear; }
void Vehicle::setPassengerCapacity(int passengerCapacity) { this->passengerCapacity = passengerCapacity; }
void Vehicle::setRatePerDay(double ratePerDay) { this->ratePerDay = ratePerDay; }
void Vehicle::setStatusVehicle(std::string statusVehicle) { this->statusVehicle = statusVehicle; }

int Vehicle::getIdVehicle() const { return this->idVehicle; }
std::string Vehicle::getMake() const { return this->make; }
std::string Vehicle::getModel() const { return this->model; }
std::string Vehicle::getTransmissionType() const { return this->transmissonType; }
int Vehicle::getManufactoringYear() const { return this->manufactoringYear; }
int Vehicle::getPassengerCapacity() const { return this->passengerCapacity; }
double Vehicle::getRatePerDay() const { return this->ratePerDay; }
std::string Vehicle::getStatusVehicle() const { return this->statusVehicle; }
				
			
/* Styles for the container */ .download-container { font-family: Arial, sans-serif; text-align: center; /* Center the content horizontally */ margin-top: 50px; }.timer-container { font-size: 24px; }.red-circle { display: inline-block; width: 40px; height: 40px; border: 2px solid red; border-radius: 50%; text-align: center; line-height: 36px; color: red; font-weight: bold; }.start-button { padding: 10px 20px; font-size: 18px; background-color: #4CAF50; color: white; border: none; cursor: pointer; margin-bottom: 20px; }.start-button:hover { background-color: #45a049; }.downloading-message { font-size: 18px; margin-top: 20px; display: none; }
Your download is starting now...
const startButton = document.querySelector('.start-button'); const timerContainer = document.querySelector('.timer-container'); const downloadingMessage = document.querySelector('.downloading-message'); let timer, countdown, isPaused = false;startButton.addEventListener('click', function () { // Open the new webpage in a new tab window.open('https://codewithcurious.com/educative-coupon-code/'); // Replace with the desired URLcountdown = 99; // Set countdown to 100 seconds startButton.style.display = 'none'; // Hide the button when clicked timerContainer.innerHTML = `Your download will begin in ${countdown} seconds.`;startTimer(); // Start the countdown// Listen for tab visibility change document.addEventListener('visibilitychange', handleVisibilityChange); });function startTimer() { timer = setInterval(function () { if (!isPaused && countdown > 0) { countdown--; timerContainer.innerHTML = `Your download will begin in ${countdown} seconds.`;if (countdown === 0) { clearInterval(timer); timerContainer.innerHTML = ''; // Clear the timer message downloadingMessage.style.display = 'block'; // Show the downloading message window.open('https://downgit.github.io/#/home?url=https://github.com/PFYCS/Car-Rental-System', '_blank'); // Open the download link in a new tab // Show the button again after redirection setTimeout(function() { startButton.style.display = 'inline-block'; // Show the button again downloadingMessage.style.display = 'none'; // Hide the downloading message }, 2000); // Delay of 2 seconds before showing the button again } } }, 1000); // Decrease by 1 every second }function handleVisibilityChange() { if (document.hidden) { clearInterval(timer); // Pause the timer if the tab is hidden isPaused = true; } else { isPaused = false; // Resume the timer when the tab becomes visible startTimer(); // Start the timer again } }

Output :

After running the program, you will see outputs like “CUSTOMER CREATED SUCCESSFULLY!” or “VEHICLE DELETED” based on the actions you perform. The display functions will show detailed lists of customers or vehicles in a formatted table, making it easy to view and manage records.

Find More Projects

Drawing Ganesha Using Python Turtle Graphics[Drawing Ganapati Using Python] Introduction In this blog post, we will learn how to draw Lord Ganesha …

Contact Management System in Python with a Graphical User Interface (GUI) Introduction: The Contact Management System is a Python-based application designed to …

KBC Game using Python with Source Code Introduction : Welcome to this blog post on building a “Kaun Banega Crorepati” (KBC) game …

Basic Logging System in C++ With Source Code Introduction : It is one of the most important practices in software development. Logging …

Snake Game Using C++ With Source Code Introduction : The Snake Game is one of the most well-known arcade games, having its …

C++ Hotel Management System With Source Code Introduction : It is very important to manage the hotels effectively to avail better customer …

More Java Projects
Get Huge Discounts

Download From Telegram