sudo apt-get marks
 
Loading...
Searching...
No Matches
Citizen Class Referenceabstract

Abstract base class representing a citizen. More...

#include <Citizen.h>

Inheritance diagram for Citizen:
CommercialWorker GovernmentWorker IndustrialWorker

Public Member Functions

 Citizen ()
 Default constructor for Citizen.
 
virtual ~Citizen ()=default
 Virtual destructor for Citizen.
 
virtual void setCitizen (string type, string residence, string workplace)
 Sets the properties of the citizen.
 
virtual std::string getType ()
 Gets the type of the citizen.
 
virtual string getResidence ()
 Gets the residence of the citizen.
 
virtual string getWorkplace ()
 Gets the workplace of the citizen.
 
virtual float getSatisfaction ()
 Gets the satisfaction level of the citizen.
 
virtual void displayInfo ()=0
 Pure virtual function to display citizen information. This function must be implemented by derived classes.
 
void changeSatisfaction (float amt)
 Changes the satisfaction level of the citizen.
 

Detailed Description

Abstract base class representing a citizen.

The Citizen class serves as a base class for various types of citizens, encapsulating common properties such as residence, workplace, and satisfaction levels. This class defines the interface for all citizen types.

Member Function Documentation

◆ changeSatisfaction()

void Citizen::changeSatisfaction ( float amt)

Changes the satisfaction level of the citizen.

Parameters
amtThe amount to change satisfaction by (can be positive or negative).

◆ displayInfo()

virtual void Citizen::displayInfo ( )
pure virtual

Pure virtual function to display citizen information. This function must be implemented by derived classes.

Implemented in CommercialWorker, GovernmentWorker, and IndustrialWorker.

◆ getResidence()

std::string Citizen::getResidence ( )
virtual

Gets the residence of the citizen.

Returns
The residence of the citizen as a string.

◆ getSatisfaction()

float Citizen::getSatisfaction ( )
virtual

Gets the satisfaction level of the citizen.

Returns
The satisfaction level as a float.

◆ getType()

std::string Citizen::getType ( )
virtual

Gets the type of the citizen.

Returns
The type of the citizen as a string.

◆ getWorkplace()

std::string Citizen::getWorkplace ( )
virtual

Gets the workplace of the citizen.

Returns
The workplace of the citizen as a string.

◆ setCitizen()

void Citizen::setCitizen ( string type,
string residence,
string workplace )
virtual

Sets the properties of the citizen.

Parameters
typeThe type of the citizen.
residenceThe residence of the citizen.
workplaceThe workplace of the citizen.