From 34cb64ab1bf0ea2d89ff4230ad3e2ab0b618973a Mon Sep 17 00:00:00 2001 From: Avinash Rajesh Date: Fri, 22 May 2026 13:26:02 +0530 Subject: [PATCH] Add standardized documentation headers --- .../Trenser.VehicleServiceSystem.vcxproj | 1 + .../controllers/Controller.cpp | 74 ++++++++ .../controllers/Controller.h | 8 + .../models/ServiceBooking.cpp | 162 +++++++++++++++++- .../models/ServiceBooking.h | 8 + .../AuthenticationManagementService.cpp | 37 ++++ .../AuthenticationManagementService.h | 8 + .../services/ServiceManagementService.cpp | 30 ++++ .../services/ServiceManagementService.h | 8 + .../services/UserManagementService.cpp | 38 ++++ .../services/UserManagementService.h | 8 + .../utilities/Config.h | 8 + .../utilities/Utility.h | 21 +++ .../views/CustomerMenu.cpp | 64 +++++++ .../views/CustomerMenu.h | 9 + .../views/MenuHelper.h | 16 ++ .../views/UserInterface.cpp | 36 ++++ .../views/UserInterface.h | 9 + 18 files changed, 544 insertions(+), 1 deletion(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj index 0cb9d3f..063f776 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem.vcxproj @@ -182,6 +182,7 @@ + diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index b92c3aa..893494e 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -1,28 +1,71 @@ +/* +File: Controller.cpp +Description: Implementation file containing the method definitions of the + Controller class, including authentication, user creation, + service purchasing, and system checks. +Author: Trenser +Date:19-May-2026 +*/ #include #include "Controller.h" #include "Enums.h" #include "User.h" +/* +Function: login +Description: Authenticates a user by delegating to the authentication management service. +Parameter: const std::string& username - user’s username + const std::string& password - user’s password +Return type: bool - true if login successful, false otherwise +*/ bool Controller::login(const std::string& username, const std::string& password) { return m_authenticationManagementService.login(username, password); } +/* +Function: logout +Description: Logs out the currently authenticated user. +Parameter: None +Return type: void +*/ void Controller::logout() { m_authenticationManagementService.logout(); } +/* +Function: changePassword +Description: Changes the password of the currently authenticated user. +Parameter: const std::string& newPassword - new password to set +Return type: void +*/ void Controller::changePassword(const std::string& newPassword) { m_authenticationManagementService.changePassword(newPassword); } +/* +Function: createCustomer +Description: Creates a new customer account with the provided details. +Parameter: const std::string& username - customer’s username + const std::string& name - customer’s name + const std::string& password - customer’s password + const std::string& email - customer’s email + const std::string& phone - customer’s phone number +Return type: void +*/ void Controller::createCustomer(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone) { m_userManagementService.createUser(username, name, password, email, phone, util::UserType::CUSTOMER); } +/* +Function: getAuthenticatedUser +Description: Retrieves the currently authenticated user. +Parameter: None +Return type: const User* - pointer to the authenticated user +*/ const User* Controller::getAuthenticatedUser() { return m_authenticationManagementService.getAuthenticatedUser(); @@ -32,6 +75,13 @@ void Controller::createTechnician(const std::string& username, const std::string { } +/* +Function: updateUserDetails +Description: Updates the email and phone details of the currently authenticated user. +Parameter: const std::string& email - new email address + const std::string& phone - new phone number +Return type: void +*/ void Controller::updateUserDetails(const std::string& email, const std::string& phone) { User* authenticatedUser = m_authenticationManagementService.getAuthenticatedUser(); @@ -52,11 +102,29 @@ util::Map Controller::getComboPackages() return util::Map(); } +/* +Function: purchaseService +Description: Purchases one or more services for a vehicle by delegating to the service management service. +Parameter: const util::Vector& serviceIDs - IDs of services to purchase + const std::string& vehicleNumber - vehicle registration number + const std::string& vehicleBrand - brand of the vehicle + const std::string& vehicleModel - model of the vehicle +Return type: void +*/ void Controller::purchaseService(const util::Vector& serviceIDs, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel) { m_serviceManagementService.purchaseService(serviceIDs, vehicleNumber, vehicleBrand, vehicleModel); } +/* +Function: purchaseComboPackage +Description: Purchases a combo package for a vehicle by delegating to the service management service. +Parameter: const std::string& comboPackageID - ID of the combo package + const std::string& vehicleNumber - vehicle registration number + const std::string& vehicleBrand - brand of the vehicle + const std::string& vehicleModel - model of the vehicle +Return type: void +*/ void Controller::purchaseComboPackage(const std::string& comboPackageID, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel) { m_serviceManagementService.purchaseComboPackage(comboPackageID, vehicleNumber, vehicleBrand, vehicleModel); @@ -155,6 +223,12 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN { } +/* +Function: runSystemChecks +Description: Runs system checks to ensure critical configurations, such as verifying admin existence. +Parameter: None +Return type: void +*/ void Controller::runSystemChecks() { m_userManagementService.ensureAdminExists(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index dddbb94..027ca20 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -1,3 +1,11 @@ +/* +File: Controller.h +Description: Header file declaring the Controller class, which coordinates + authentication, user management, service management, inventory, + and notifications across the Vehicle Service System. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include "Map.h" #include diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp index 51fc6ff..c7a4d88 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.cpp @@ -1,13 +1,42 @@ +/* +File: ServiceBooking.cpp +Description: Implementation file containing the method definitions of the + ServiceBooking class, including constructors, getters, and setters + for booking attributes. +Author: Trenser +Date:19-May-2026 +*/ #include "ServiceBooking.h" int ServiceBooking::m_uid = 0; +/* +Function: ServiceBooking +Description: Default constructor that initializes a new service booking + with a unique ID, no customer or technician, and zero discount. +Parameter: None +Return type: Constructor +*/ ServiceBooking::ServiceBooking() : m_id("SRV" + std::to_string(++m_uid)), m_customer(nullptr), m_assignedTechnician(nullptr), m_discountPercentage(0.0) {} +/* +Function: ServiceBooking +Description: Parameterized constructor that initializes a service booking + with customer, vehicle, services, and discount details. +Parameter: util::ServiceJobStatus status - current booking status + const util::Map& services - map of services + const std::string& customerId - ID of the customer + User* customer - pointer to the customer object + const std::string& vehicleNumber - vehicle registration number + const std::string& vehicleBrand - brand of the vehicle + const std::string& vehicleModel - model of the vehicle + double discountPercentage - discount applied to the booking +Return type: Constructor +*/ ServiceBooking::ServiceBooking( util::ServiceJobStatus status, const util::Map& +*/ const util::Map& ServiceBooking::getServices() const { return m_services; } +/* +Function: getCustomerId +Description: Retrieves the customer ID associated with the booking. +Parameter: None +Return type: const std::string& +*/ const std::string& ServiceBooking::getCustomerId() const { return m_customerId; } +/* +Function: getCustomer +Description: Retrieves the customer object associated with the booking. +Parameter: None +Return type: User* +*/ User* ServiceBooking::getCustomer() const { return m_customer; } +/* +Function: getVehicleNumber +Description: Retrieves the vehicle registration number for the booking. +Parameter: None +Return type: const std::string& +*/ const std::string& ServiceBooking::getVehicleNumber() const { return m_vehicleNumber; } +/* +Function: getVehicleBrand +Description: Retrieves the brand of the vehicle for the booking. +Parameter: None +Return type: const std::string& +*/ const std::string& ServiceBooking::getVehicleBrand() const { return m_vehicleBrand; } +/* +Function: getVehicleModel +Description: Retrieves the model of the vehicle for the booking. +Parameter: None +Return type: const std::string& +*/ const std::string& ServiceBooking::getVehicleModel() const { return m_vehicleModel; } +/* +Function: getAssignedTechnicianId +Description: Retrieves the ID of the technician assigned to the booking. +Parameter: None +Return type: const std::string& +*/ const std::string& ServiceBooking::getAssignedTechnicianId() const { return m_assignedTechnicianId; } +/* +Function: getAssignedTechnician +Description: Retrieves the technician object assigned to the booking. +Parameter: None +Return type: User* +*/ User* ServiceBooking::getAssignedTechnician() const { return m_assignedTechnician; } - +/* +Function: getDiscountPercentage +Description: Retrieves the discount percentage applied to the booking. +Parameter: None +Return type: double +*/ double ServiceBooking::getDiscountPercentage() const { return m_discountPercentage; } +/* +Function: setId +Description: Sets the unique identifier of the service booking. +Parameter: const std::string& id - new booking ID +Return type: void +*/ void ServiceBooking::setId(const std::string& id) { m_id = id; } +/* +Function: setStatus +Description: Sets the current status of the service booking. +Parameter: const util::ServiceJobStatus& status - new booking status +Return type: void +*/ void ServiceBooking::setStatus(const util::ServiceJobStatus& status) { m_status = status; } +/* +Function: setServices +Description: Sets the services associated with the booking. +Parameter: const util::Map& services - new services map +Return type: void +*/ void ServiceBooking::setServices(const util::Map& services) { m_services = services; } +/* +Function: setCustomerId +Description: Sets the customer ID for the booking. +Parameter: const std::string& customerId - new customer ID +Return type: void +*/ void ServiceBooking::setCustomerId(const std::string& customerId) { m_customerId = customerId; } +/* +Function: setCustomer +Description: Sets the customer object for the booking. +Parameter: User* customer - pointer to the customer object +Return type: void +*/ void ServiceBooking::setCustomer(User* customer) { m_customer = customer; } +/* +Function: setVehicleNumber +Description: Sets the vehicle registration number for the booking. +Parameter: const std::string& vehicleNumber - new vehicle number +Return type: void +*/ void ServiceBooking::setVehicleNumber(const std::string& vehicleNumber) { m_vehicleNumber = vehicleNumber; } +/* +Function: setVehicleBrand +Description: Sets the brand of the vehicle for the booking. +Parameter: const std::string& vehicleBrand - new vehicle brand +Return type: void +*/ void ServiceBooking::setVehicleBrand(const std::string& vehicleBrand) { m_vehicleBrand = vehicleBrand; } +/* +Function: setVehicleModel +Description: Sets the model of the vehicle for the booking. +Parameter: const std::string& vehicleModel - new vehicle model +Return type: void +*/ void ServiceBooking::setVehicleModel(const std::string& vehicleModel) { m_vehicleModel = vehicleModel; } +/* +Function: setAssignedTechnicianId +Description: Sets the ID of the technician assigned to the booking. +Parameter: const std::string& assignedTechnicianId - new technician ID +Return type: void +*/ void ServiceBooking::setAssignedTechnicianId(const std::string& assignedTechnicianId) { m_assignedTechnicianId = assignedTechnicianId; } +/* +Function: setAssignedTechnician +Description: Sets the technician object assigned to the booking. +Parameter: User* assignedTechnician - pointer to the technician object +Return type: void +*/ void ServiceBooking::setAssignedTechnician(User* assignedTechnician) { m_assignedTechnician = assignedTechnician; } +/* +Function: setDiscountPercentage +Description: Sets the discount percentage for the booking. +Parameter: double discountPercentage - new discount percentage +Return type: void +*/ void ServiceBooking::setDiscountPercentage(double discountPercentage) { m_discountPercentage = discountPercentage; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h index 84a8aac..48e3ba9 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/models/ServiceBooking.h @@ -1,3 +1,11 @@ +/* +File: ServiceBooking.h +Description: Header file declaring the ServiceBooking class, which represents + a booking of services by a customer, including vehicle details, + assigned technician, and discount information. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp index 36c2080..d6fd4b6 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp @@ -1,9 +1,26 @@ +/* +File: AuthenticationManagementService.cpp +Description: Implementation file containing the method definitions of the + AuthenticationManagementService class, including login, logout, + password change, and retrieval of the authenticated user. +Author: Trenser +Date:19-May-2026 +*/ #include #include "AuthenticationManagementService.h" #include "User.h" User* AuthenticationManagementService::m_authenticatedUser = nullptr; +/* +Function: login +Description: Authenticates a user by checking the provided username and password + against the stored users in the DataStore. If successful, sets the + authenticated user. +Parameter: const std::string& username - user’s username + const std::string& password - user’s password +Return type: bool - true if login successful, false otherwise +*/ bool AuthenticationManagementService::login(const std::string& username, const std::string& password) { util::Map users = m_dataStore.getUsers(); @@ -24,16 +41,36 @@ bool AuthenticationManagementService::login(const std::string& username, const s return false; } +/* +Function: getAuthenticatedUser +Description: Retrieves the currently authenticated user. +Parameter: None +Return type: User* - pointer to the authenticated user +*/ User* AuthenticationManagementService::getAuthenticatedUser() { return m_authenticatedUser; } +/* +Function: logout +Description: Logs out the currently authenticated user by clearing the + static authenticated user pointer. +Parameter: None +Return type: void +*/ void AuthenticationManagementService::logout() { m_authenticatedUser = nullptr; } +/* +Function: changePassword +Description: Changes the password of the currently authenticated user. + Throws an exception if no user is logged in. +Parameter: const std::string& newPassword - new password to set +Return type: void +*/ void AuthenticationManagementService::changePassword(const std::string& newPassword) { if (m_authenticatedUser == nullptr) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.h index ee0ed91..e89e0c3 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.h @@ -1,3 +1,11 @@ +/* +File: AuthenticationManagementService.h +Description: Header file declaring the AuthenticationManagementService class, which manages + user authentication, login, logout, password changes, and retrieval of the + authenticated user. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include #include "DataStore.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp index 3c787b3..c720c35 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp @@ -1,3 +1,11 @@ +/* +File: ServiceManagementService.cpp +Description: Implementation file containing the method definitions of the + ServiceManagementService class, including service and combo package + purchasing logic, booking creation, and notification handling. +Author: Trenser +Date:19-May-2026 +*/ #include #include "ServiceManagementService.h" #include "AuthenticationManagementService.h" @@ -6,6 +14,17 @@ #include "ComboPackage.h" #include "Factory.h" +/* +Function: purchaseService +Description: Creates a new service booking for the authenticated user. Validates + service IDs, retrieves services from the DataStore, and generates a + booking. Sends a notification upon successful booking. +Parameter: const util::Vector& serviceIDs - IDs of services to purchase + const std::string& vehicleNumber - vehicle registration number + const std::string& vehicleBrand - brand of the vehicle + const std::string& vehicleModel - model of the vehicle +Return type: void +*/ void ServiceManagementService::purchaseService(const util::Vector& serviceIDs, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel) { AuthenticationManagementService m_authenticationManagementService; @@ -39,6 +58,17 @@ void ServiceManagementService::purchaseService(const util::Vector& "Your service booking has been successfully placed with ID " + serviceBooking->getId()); } +/* +Function: purchaseComboPackage +Description: Creates a new service booking for a combo package. Validates the combo + package ID, retrieves services from the package, and generates a booking + with the applicable discount. Sends a notification upon successful booking. +Parameter: const std::string& comboPackageID - ID of the combo package + const std::string& vehicleNumber - vehicle registration number + const std::string& vehicleBrand - brand of the vehicle + const std::string& vehicleModel - model of the vehicle +Return type: void +*/ void ServiceManagementService::purchaseComboPackage(const std::string& comboPackageID, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel) { AuthenticationManagementService m_authenticationManagementService; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h index 85e05ed..e1dfb91 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.h @@ -1,3 +1,11 @@ +/* +File: ServiceManagementService.h +Description: Header file declaring the ServiceManagementService class, which manages + services, combo packages, job cards, and service bookings. Inherits from + NotificationManagementService to handle notifications. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp index 395e12f..9036731 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.cpp @@ -1,3 +1,11 @@ +/* +File: UserManagementService.cpp +Description: Implementation file containing the method definitions of the + UserManagementService class, including user creation, updates, + and ensuring an admin account exists. +Author: Trenser +Date:19-May-2026 +*/ #include #include "User.h" #include "Enums.h" @@ -8,6 +16,14 @@ #include "InventoryManagementService.h" #include "Factory.h" +/* +Function: ensureAdminExists +Description: Ensures that at least one admin user exists in the system. + If no admin is found, creates a default admin user using + configuration constants. +Parameter: None +Return type: void +*/ void UserManagementService::ensureAdminExists() { auto& usersMap = m_dataStore.getUsers(); @@ -34,6 +50,19 @@ void UserManagementService::ensureAdminExists() } } +/* +Function: createUser +Description: Creates a new user with the provided details. Validates that + the username is unique, then attaches the user to relevant + management services (payment, service, inventory). +Parameter: const std::string& username - user’s username + const std::string& name - user’s name + const std::string& password - user’s password + const std::string& email - user’s email address + const std::string& phone - user’s phone number + util::UserType type - type of user (ADMIN, CUSTOMER, TECHNICIAN) +Return type: void +*/ void UserManagementService::createUser(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone, util::UserType type) { InventoryManagementService inventoryManagementService; @@ -60,6 +89,15 @@ void UserManagementService::createUser(const std::string& username, const std::s } } +/* +Function: updateUserDetails +Description: Updates the email and phone details of an existing user. + Throws an exception if the user does not exist. +Parameter: const std::string& userID - ID of the user to update + const std::string& email - new email address + const std::string& phone - new phone number +Return type: void +*/ void UserManagementService::updateUserDetails(const std::string& userID, const std::string& email, const std::string& phone) { auto& usersMap = m_dataStore.getUsers(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h index 34603a4..5b89053 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/UserManagementService.h @@ -1,3 +1,11 @@ +/* +File: UserManagementService.h +Description: Header file declaring the UserManagementService class, which manages + user creation, updates, retrieval, removal, notifications, and ensures + the existence of an admin account. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include #include "Map.h" diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h index 38c7bed..ca5ea0e 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Config.h @@ -1,3 +1,11 @@ +/* +File: Config.h +Description: Header file declaring configuration constants for the Vehicle Service System. + Includes default admin account details such as username, name, password, + email, and phone number. +Author: Trenser +Date:19-May-2026 +*/ #pragma once namespace config diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h index dcbe33e..ca1fd37 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/utilities/Utility.h @@ -1,7 +1,21 @@ +/* +File: Utility.h +Description: Header file declaring utility functions used across the system, + including cost calculation for services and combo packages. +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include "Service.h" #include "InventoryItem.h" +/* +Function: calculatePartsCost +Description: Calculates the total cost of parts required for a given service + by summing the prices of all associated inventory items. +Parameter: const Service* service - pointer to the service object +Return type: double - total cost of required parts +*/ inline double calculatePartsCost(const Service* service) { double cost = 0; @@ -14,6 +28,13 @@ inline double calculatePartsCost(const Service* service) return cost; } +/* +Function: calculateComboServiceEstimatedCost +Description: Calculates the estimated total cost of a combo package by summing + the labor and parts costs of all services included in the package. +Parameter: const ComboPackage* comboPackage - pointer to the combo package object +Return type: double - estimated total cost of the combo package +*/ inline double calculateComboServiceEstimatedCost(const ComboPackage* comboPackage) { double cost = 0; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index 0a97c6a..b9a6d23 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -1,3 +1,11 @@ +/* +File: CustomerMenu.cpp +Description: Implementation file containing the method definitions of the + CustomerMenu class, including menu handling, service selection, + combo package booking, profile updates, and password management. +Author: Trenser +Date:19-May-2026 +*/ #include #include "CustomerMenu.h" #include "Service.h" @@ -11,6 +19,12 @@ #include "Utility.h" #include "Map.h" +/* +Function: showMenu +Description: Displays the customer menu and handles user input until logout is selected. +Parameter: None +Return type: void +*/ void CustomerMenu::showMenu() { while (true) @@ -45,6 +59,12 @@ void CustomerMenu::showMenu() } } +/* +Function: handleOperation +Description: Executes the corresponding customer operation based on the selected menu choice. +Parameter: int choice - selected menu option +Return type: bool - true if menu continues, false if logout +*/ bool CustomerMenu::handleOperation(int choice) { switch (choice) @@ -86,11 +106,23 @@ bool CustomerMenu::handleOperation(int choice) return true; } +/* +Function: logout +Description: Logs out the currently authenticated customer user. +Parameter: None +Return type: void +*/ void CustomerMenu::logout() { m_controller.logout(); } +/* +Function: changePassword +Description: Allows the customer to change their password after validation. +Parameter: None +Return type: void +*/ void CustomerMenu::changePassword() { std::string newPassword; @@ -108,6 +140,12 @@ void CustomerMenu::changePassword() util::pressEnter(); } +/* +Function: updateDetails +Description: Allows the customer to update their email and phone number after validation. +Parameter: None +Return type: void +*/ void CustomerMenu::updateDetails() { std::string email, phone; @@ -133,6 +171,12 @@ void CustomerMenu::updateDetails() util::pressEnter(); } +/* +Function: selectServiceFromServices +Description: Displays active services and allows the customer to select one by index. +Parameter: const util::Map& services - list of services +Return type: const Service* - selected service +*/ static const Service* selectServiceFromServices(const util::Map& services) { util::Map activeServicesMap; @@ -176,6 +220,13 @@ static const Service* selectServiceFromServices(const util::Map& comboPackages - list of combo packages +Return type: const ComboPackage* - selected combo package +*/ static const ComboPackage* selectComboPackageFromPackages(const util::Map& comboPackages) { util::Map activeComboPackages; @@ -244,6 +301,13 @@ static const ComboPackage* selectComboPackageFromPackages(const util::Map #include @@ -6,6 +14,14 @@ #include "InputHelper.h" #include "OutputHelper.h" +/* +Function: selectNotification +Description: Displays a list of notifications with index, ID, title, and timestamp. + Allows the user to select a notification by index. Returns the selected + notification or nullptr if the selection is invalid. +Parameter: const util::Vector& notifications - list of notifications +Return type: const Notification* - pointer to the selected notification +*/ inline const Notification* selectNotification(const util::Vector& notifications) { if (notifications.getSize() == 0) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp index 6e4e26f..e774b1d 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.cpp @@ -1,3 +1,11 @@ +/* +File: UserInterface.cpp +Description: Implementation file containing the method definitions of the + UserInterface class, including system run loop, login handling, + and customer registration logic. +Author: Trenser +Date:19-May-2026 +*/ #include "UserInterface.h" #include "InputHelper.h" #include "OutputHelper.h" @@ -5,6 +13,13 @@ #include "User.h" #include "Validator.h" +/* +Function: run +Description: Runs the main system loop, displaying the initial menu for login, + customer registration, or exit. Handles exceptions gracefully. +Parameter: None +Return type: void +*/ void UserInterface::run() { bool isMenuActive = true; @@ -29,6 +44,12 @@ void UserInterface::run() } } +/* +Function: handleOperation +Description: Executes the corresponding system operation based on the selected menu choice. +Parameter: int choice - selected menu option +Return type: bool - true if menu continues, false if exit +*/ bool UserInterface::handleOperation(int choice) { switch (choice) @@ -49,6 +70,13 @@ bool UserInterface::handleOperation(int choice) return true; } +/* +Function: login +Description: Handles user login by validating credentials. Based on the authenticated + user type, navigates to the appropriate menu (Admin, Technician, Customer). +Parameter: None +Return type: void +*/ void UserInterface::login() { std::string username, password; @@ -85,6 +113,14 @@ void UserInterface::login() } } +/* +Function: registerCustomer +Description: Registers a new customer by collecting and validating details such as + username, name, email, password, and phone number. Delegates creation + to the controller. +Parameter: None +Return type: void +*/ void UserInterface::registerCustomer() { std::string username, name, email, phone, password; diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.h index da3862e..52c2beb 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/UserInterface.h @@ -1,3 +1,12 @@ +/* +File: UserInterface.h +Description: Header file declaring the UserInterface class, which provides + the main entry point for the Vehicle Service System. Handles + login, customer registration, and menu navigation for different + user roles (Admin, Technician, Customer). +Author: Trenser +Date:19-May-2026 +*/ #pragma once #include "Controller.h" #include "AdminMenu.h"