-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoctorsOffice.cpp
More file actions
99 lines (87 loc) · 2.21 KB
/
Copy pathDoctorsOffice.cpp
File metadata and controls
99 lines (87 loc) · 2.21 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "DoctorsOffice.h"
DoctorsOffice::DoctorsOffice()
{
display_code = 'D';
vaccine_capacity = 100;
num_vaccine_remaining = vaccine_capacity;
dollar_cost_per_vaccine = 5;
state = VACCINE_AVAILABLE;
cout << "DoctorsOffice default constructed" << endl;
}
DoctorsOffice::~DoctorsOffice()
{
cout << "Doctor's Office destructed" << endl;
}
DoctorsOffice::DoctorsOffice(int in_id, double vaccine_cost, unsigned int vaccine_cap, Point2D in_loc) : Building('D', in_id, in_loc)
{
dollar_cost_per_vaccine = vaccine_cost;
vaccine_capacity = vaccine_cap;
num_vaccine_remaining = vaccine_capacity;
state = VACCINE_AVAILABLE;
cout << "DoctorsOfffice constructed" << endl;
}
bool DoctorsOffice::HasVaccine()
{
if (this->num_vaccine_remaining == 0)
return false;
else
return true;
}
unsigned int DoctorsOffice::GetNumVaccineRemaining()
{
return num_vaccine_remaining;
}
bool DoctorsOffice::CanAffordVaccine(unsigned int vaccine, double budget)
{
if (vaccine * dollar_cost_per_vaccine - budget >= 0)
return true;
else
return false;
}
double DoctorsOffice::GetDollarCost(unsigned int vaccine)
{
return dollar_cost_per_vaccine * vaccine;
}
unsigned int DoctorsOffice::DistributeVaccine(unsigned int vaccine_needed)
{
if (num_vaccine_remaining >= vaccine_needed)
{
this->num_vaccine_remaining = this->num_vaccine_remaining - vaccine_needed;
return vaccine_needed;
}
else
{
int returnVal_vaccine = this->num_vaccine_remaining;
this->num_vaccine_remaining = 0;
return returnVal_vaccine;
}
}
bool DoctorsOffice::Update()
{
if (this->num_vaccine_remaining == 0)
{
state = NO_VACCINE_AVAILABLE;
display_code = 'd';
cout << "DoctorsOffice " << id_num << "has ran out of vaccine." << endl;
return true;
}
else
return false;
}
bool DoctorsOffice::ShouldBeVisible()
{
if (this->GetNumVaccineRemaining() == 0)
return false;
else
return true;
}
void DoctorsOffice::ShowStatus()
{
cout << "Doctors Office Status: " << endl;
Building::ShowStatus();
cout << " " << "Dollars per vaccine: " << dollar_cost_per_vaccine << endl;
if(num_vaccine_remaining!=1)
cout << " has " << num_vaccine_remaining << " vaccines remaining" << endl;
else
cout << " has " << num_vaccine_remaining << " vaccine remaining" << endl;
}