Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
4000CEMGameGithub/utilities.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
97 lines (83 sloc)
1.81 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include <string> | |
class cityUtilities | |
{ | |
/* This class will contain all the utilities in the city, e.g, water, electricity, gas and garbage. */ | |
public: | |
float happiness; | |
int demand; | |
int elecSupply; | |
int gasSupply; | |
int waterSupply; | |
int garbageSupply; | |
int buildingsTotalDemand; | |
int buildingsTotalDemand = 0 ; /* TO BE COMPLETED- This will calculate how much demand the buildings have */ | |
/*Electricity*/ | |
int electricity(int demand) | |
{ | |
/* This function takes in the demand of electricity and checks it against the supply */ | |
void demandSum(); | |
{ | |
demand = buildingsTotalDemand + demand; | |
if (demand >= elecSupply + 3) | |
{ | |
happiness = happiness; | |
} | |
else if (demand <= elecSupply + 4) | |
{ | |
happiness = happiness * 0.95; | |
} | |
} | |
} | |
/*Gas*/ | |
int gas(int demand) | |
{ | |
/* This function takes in the demand of electricity and checks it against the supply */ | |
void demandSum(); | |
{ | |
demand = buildingsTotalDemand + demand; | |
if (demand >= gasSupply + 3) | |
{ | |
happiness = happiness; | |
} | |
else if (demand <= gasSupply + 4) | |
{ | |
happiness = happiness * 0.95; | |
} | |
} | |
} | |
/*Water*/ | |
int water(int demand) | |
{ | |
/* This function takes in the demand of water and checks it against the supply */ | |
void demandSum(); | |
{ | |
demand = buildingsTotalDemand + demand; | |
if (demand >= waterSupply + 3) | |
{ | |
happiness = happiness; | |
} | |
else if (demand <= waterSupply + 4) | |
{ | |
happiness = happiness * 0.95; | |
} | |
} | |
} | |
/*Garbage*/ | |
int garbage(int demand) | |
{ | |
/* This function takes in the demand of garbage and checks it against the supply */ | |
void demandSum(); | |
{ | |
demand = buildingsTotalDemand + demand; | |
if (demand >= garbageSupply + 3) | |
{ | |
happiness = happiness; | |
} | |
else if (demand <= garbageSupply + 4) | |
{ | |
happiness = happiness * 0.95; | |
} | |
} | |
} | |
}; |