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

Singleton class representing water resources in the city. More...

#include <Resources.h>

Inheritance diagram for Water:
Resources

Public Member Functions

 Water (const Water &)=delete
 
void operator= (const Water &)=delete
 
int getLiters () const
 Gets the total amount of water available.
 
void setliters (int value)
 Sets the total amount of water available.
 
- Public Member Functions inherited from Resources
 Resources ()
 Default constructor for Resources.
 

Static Public Member Functions

static WatergetInstance ()
 Gets the singleton instance of the Water class.
 

Detailed Description

Singleton class representing water resources in the city.

The Water class manages the water supply in the city, tracking the total amount of water available in liters. It follows the Singleton design pattern to ensure that only one instance of this class exists throughout the application.

Member Function Documentation

◆ getInstance()

Water * Water::getInstance ( )
static

Gets the singleton instance of the Water class.

Returns
A pointer to the singleton Water instance.

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

◆ getLiters()

int Water::getLiters ( ) const
inline

Gets the total amount of water available.

Returns
The total amount of water (in liters).

◆ setliters()

void Water::setliters ( int value)
inline

Sets the total amount of water available.

Parameters
valueThe amount of water to set (in liters).