30 lines
975 B
C
30 lines
975 B
C
/*
|
|
File: Utility.h
|
|
Description: Header file declaring utility functions used across the system,
|
|
including cost calculation for services based on required inventory items.
|
|
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;
|
|
auto& requiredInventoryItems = service->getRequiredInventoryItems();
|
|
int requiredInventoryItemsSize = requiredInventoryItems.getSize();
|
|
for (int index = 0; index < requiredInventoryItemsSize; index++)
|
|
{
|
|
cost += requiredInventoryItems.getValueAt(index)->getPrice();
|
|
}
|
|
return cost;
|
|
}
|