310 lines
7.9 KiB
C++
310 lines
7.9 KiB
C++
/*
|
|
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, and zero discount.
|
|
Parameter: None
|
|
Return type: Constructor
|
|
*/
|
|
ServiceBooking::ServiceBooking()
|
|
: m_id("SRV" + std::to_string(++m_uid)),
|
|
m_customer(nullptr),
|
|
m_discountPercentage(0.0) {}
|
|
|
|
/*
|
|
Function: ServiceBooking
|
|
Description: Parameterized constructor that initializes a service booking
|
|
with customer, vehicle, technician, and discount details.
|
|
Parameter: const std::string& id - booking ID
|
|
util::ServiceJobStatus status - current booking status
|
|
const util::Map<std::string, Service*>& 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
|
|
const std::string& assignedTechnicianId - ID of the assigned technician
|
|
User* assignedTechnician - pointer to the technician object
|
|
double discountPercentage - discount applied to the booking
|
|
Return type: Constructor
|
|
*/
|
|
ServiceBooking::ServiceBooking(
|
|
const std::string& id,
|
|
util::ServiceJobStatus status,
|
|
const util::Map<std::string,
|
|
Service*>& services,
|
|
const std::string& customerId,
|
|
User* customer,
|
|
const std::string& vehicleNumber,
|
|
const std::string& vehicleBrand,
|
|
const std::string& vehicleModel,
|
|
const std::string& assignedTechnicianId,
|
|
User* assignedTechnician,
|
|
double discountPercentage
|
|
)
|
|
: m_id("SRV" + std::to_string(++m_uid)),
|
|
m_status(status),
|
|
m_services(services),
|
|
m_customerId(customerId),
|
|
m_customer(customer),
|
|
m_vehicleNumber(vehicleNumber),
|
|
m_vehicleBrand(vehicleBrand),
|
|
m_vehicleModel(vehicleModel),
|
|
m_assignedTechnicianId(assignedTechnicianId),
|
|
m_assignedTechnician(assignedTechnician),
|
|
m_discountPercentage(discountPercentage)
|
|
{
|
|
}
|
|
|
|
/*
|
|
Function: getId
|
|
Description: Retrieves the unique identifier of the service booking.
|
|
Parameter: None
|
|
Return type: const std::string&
|
|
*/
|
|
const std::string& ServiceBooking::getId() const
|
|
{
|
|
return m_id;
|
|
}
|
|
|
|
/*
|
|
Function: getStatus
|
|
Description: Retrieves the current status of the service booking.
|
|
Parameter: None
|
|
Return type: util::ServiceJobStatus
|
|
*/
|
|
util::ServiceJobStatus ServiceBooking::getStatus() const
|
|
{
|
|
return m_status;
|
|
}
|
|
|
|
/*
|
|
Function: getServices
|
|
Description: Retrieves the services associated with the booking.
|
|
Parameter: None
|
|
Return type: const util::Map<std::string, Service*>&
|
|
*/
|
|
const util::Map<std::string, Service*>& 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<std::string, Service*>& services - new services map
|
|
Return type: void
|
|
*/
|
|
void ServiceBooking::setServices(const util::Map<std::string, Service*>& 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;
|
|
} |