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

Abstract base class representing a generic building. More...

#include <Buildings.h>

Inheritance diagram for Building:
Commercial Industrial Instatutional Residential Mall Office Shop Factory Plant Warehouse GovernmentBuilding Hospital School Apartment House Mansion

Public Member Functions

 Building (std::string name, int numRooms, int m_squared, float value, std::string type)
 Constructor to initialize a Building object.
 
virtual ~Building ()
 Virtual destructor for the Building class.
 
std::vector< Citizen * > getCitizens () const
 Gets the list of citizens in the building.
 
virtual void build ()=0
 Pure virtual function to build the building.
 
virtual Buildingclone ()=0
 Pure virtual function to clone the building object.
 
virtual void displayCitizens ()
 Displays the list of citizens in the building.
 
virtual void addCitizen (Citizen *human)=0
 Pure virtual function to add a citizen to the building.
 
virtual int getLeftOverCapacity ()=0
 Pure virtual function to get the leftover capacity of the building.
 
virtual std::string getType () const =0
 Pure virtual function to get the type of the building.
 
std::string getName ()
 Gets the name of the building.
 
std::string getBuildingType ()
 Gets the building's type description.
 
bool getBuilt () const
 Checks if the building is built.
 
void renovate ()
 Renovates the building, updating any necessary properties.
 

Protected Attributes

std::string name
 Name of the building.
 
std::string type
 Type of the building (e.g., Residential, Commercial)
 
int numRooms
 Number of rooms in the building.
 
int m_squared
 Area of the building in square meters.
 
float value
 Value of the building.
 
bool built = false
 Flag indicating if the building is built.
 
Budgetbudget
 Pointer to a Budget object for managing building finances.
 
Concreteconcrete
 Pointer to a Concrete object for building materials.
 
Steelsteel
 Pointer to a Steel object for building materials.
 
Woodwood
 Pointer to a Wood object for building materials.
 
std::vector< Citizen * > citizens
 List of citizens associated with the building.
 

Detailed Description

Abstract base class representing a generic building.

The Building class serves as a base class for various types of buildings (e.g., Residential, Commercial). It includes essential attributes such as name, type, number of rooms, area, value, and lists of citizens. Derived classes must implement the pure virtual functions to define specific behaviors.

Constructor & Destructor Documentation

◆ Building()

Building::Building ( std::string name,
int numRooms,
int m_squared,
float value,
std::string type )

Constructor to initialize a Building object.

Parameters
nameName of the building.
numRoomsNumber of rooms in the building.
m_squaredArea of the building in square meters.
valueValue of the building.
typeType of the building.

Member Function Documentation

◆ addCitizen()

virtual void Building::addCitizen ( Citizen * human)
pure virtual

Pure virtual function to add a citizen to the building.

Parameters
humanPointer to the Citizen to be added.

Derived classes must implement this function to handle adding citizens.

Implemented in Commercial, Industrial, Instatutional, and Residential.

◆ build()

virtual void Building::build ( )
pure virtual

Pure virtual function to build the building.

Must be implemented by derived classes to define specific building construction behavior.

Implemented in Apartment, Commercial, Factory, GovernmentBuilding, Hospital, House, Industrial, Instatutional, Mall, Mansion, Office, Plant, Residential, School, Shop, and Warehouse.

◆ clone()

virtual Building * Building::clone ( )
pure virtual

Pure virtual function to clone the building object.

Returns
A pointer to a new Building object that is a clone of the current instance.

Implemented in Apartment, Commercial, Factory, GovernmentBuilding, Hospital, House, Industrial, Instatutional, Mall, Mansion, Office, Plant, Residential, School, Shop, and Warehouse.

◆ displayCitizens()

void Building::displayCitizens ( )
virtual

Displays the list of citizens in the building.

This function can be overridden by derived classes to provide specific display behavior.

Reimplemented in Commercial, Industrial, Instatutional, and Residential.

◆ getBuildingType()

std::string Building::getBuildingType ( )

Gets the building's type description.

Returns
The type of the building as a string.

◆ getBuilt()

bool Building::getBuilt ( ) const
inline

Checks if the building is built.

Returns
True if the building is built, false otherwise.

◆ getCitizens()

std::vector< Citizen * > Building::getCitizens ( ) const
inline

Gets the list of citizens in the building.

Returns
A vector of Citizen pointers.

◆ getLeftOverCapacity()

virtual int Building::getLeftOverCapacity ( )
pure virtual

Pure virtual function to get the leftover capacity of the building.

Returns
The number of additional citizens the building can accommodate.

Derived classes must implement this function to define capacity limits.

Implemented in Commercial, Industrial, Instatutional, and Residential.

◆ getName()

std::string Building::getName ( )

Gets the name of the building.

Returns
The name of the building as a string.

◆ getType()

virtual std::string Building::getType ( ) const
pure virtual

Pure virtual function to get the type of the building.

Returns
The type of the building as a string.

Implemented in Apartment, Commercial, Factory, GovernmentBuilding, Hospital, House, Industrial, Instatutional, Mall, Mansion, Office, Plant, Residential, School, Shop, and Warehouse.

◆ renovate()

void Building::renovate ( )

Renovates the building, updating any necessary properties.

This function can be overridden by derived classes to provide specific renovation behaviors.