sudo apt-get marks
 
Loading...
Searching...
No Matches
Budget Class Reference

Singleton class representing the financial budget of the city. More...

#include <Resources.h>

Inheritance diagram for Budget:
Resources

Public Member Functions

 Budget (const Budget &)=delete
 
void operator= (const Budget &)=delete
 
double getCash () const
 Gets the current amount of cash in the budget.
 
double getDebt () const
 Gets the total amount of debt incurred by the city.
 
void setCash (double cash)
 Sets the amount of cash in the budget.
 
void setDebt (double debt)
 Sets the total amount of debt incurred by the city.
 
- Public Member Functions inherited from Resources
 Resources ()
 Default constructor for Resources.
 

Static Public Member Functions

static BudgetgetInstance ()
 Gets the singleton instance of the Budget class.
 

Detailed Description

Singleton class representing the financial budget of the city.

The Budget class manages the city's financial resources, including cash and debt. It follows the Singleton design pattern to ensure that only one instance of this class exists throughout the application.

Member Function Documentation

◆ getCash()

double Budget::getCash ( ) const
inline

Gets the current amount of cash in the budget.

Returns
The amount of cash available.

◆ getDebt()

double Budget::getDebt ( ) const
inline

Gets the total amount of debt incurred by the city.

Returns
The total debt.

◆ getInstance()

Budget * Budget::getInstance ( )
static

Gets the singleton instance of the Budget class.

Returns
A pointer to the singleton Budget instance.

This method checks if an instance of the Budget class already exists; if not, it creates one and returns it. This guarantees that there is only one instance of Budget throughout the application.

◆ setCash()

void Budget::setCash ( double cash)
inline

Sets the amount of cash in the budget.

Parameters
cashThe amount of cash to set.

If the new cash amount is negative, this method will automatically set the debt to the absolute value of the cash amount.

◆ setDebt()

void Budget::setDebt ( double debt)
inline

Sets the total amount of debt incurred by the city.

Parameters
debtThe amount of debt to set.