forked from matkatmusic/PFMCPP_Project5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCity.cpp
More file actions
72 lines (58 loc) · 1.75 KB
/
Copy pathCity.cpp
File metadata and controls
72 lines (58 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <iostream>
#include "City.h"
City::City() : name("Montreal"), country("Canada"), population(5000000)
{
std::cout << "City being constructed." << std::endl;
}
City::~City()
{
std::cout << "City being deconstructed." << std::endl;
}
City::PoliceDepartment::PoliceDepartment() : staff(4500), budgetMillions(500), salary(85000)
{
std::cout << "PoliceDepartment being constructed." << std::endl;
}
City::PoliceDepartment::~PoliceDepartment()
{
std::cout << "PoliceDepartment being deconstructed." << std::endl;
}
void City::aboutCity() const
{
std::cout << "The city named " << this->name << " has a population of " << this->population << std::endl;
}
void City::expand(float expansionRate)
{
if(expansionRate < 0.f)
{
std::cout << "we're shrinking!" << std::endl;
}
}
std::string City::createLaw() const
{
return newLawName;
}
int City::updatePopulation(int immigrantsYear, int emigrantsYear, int birthsYear, int deathsYear, int years)
{
for(int i = 0; i <= years; ++i)
{
population = population + immigrantsYear - emigrantsYear + birthsYear - deathsYear;
}
return population;
}
float City::PoliceDepartment::getConvictionRate(float arrests, float convictions) const
{
float rate = convictions / arrests;
std::cout << rate << " is the conviction rate." << std::endl;
return rate;
}
void City::PoliceDepartment::trainRookies(int rookies, int monthsTraining) const
{
for (int i = 1; i <= monthsTraining; ++i)
{
std::cout << i * rookies << " combined months of training costs." << std::endl;
}
}
void City::PoliceDepartment::aboutPolice() const
{
std::cout << "The police have " << this->staff << " staff, and a chief named " << this->chief << std::endl;
}