-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoom.cpp
More file actions
226 lines (187 loc) · 4.29 KB
/
Room.cpp
File metadata and controls
226 lines (187 loc) · 4.29 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#include <iostream>
#include <string>
#include "Room.h"
#include "Functions.h"
using namespace std;
// constructor
Room::Room()
{
roomType = '-';
roomNumber = 0;
status = "VACANT";
totalRoomCost = 0;
duration = "0";
cout << "Room constructor called" << endl;
}
// return room type
char Room::getRoomType()
{
return roomType;
}
// set room number
void Room::setRoomNumber(int roomNo)
{
roomNumber = roomNo;
}
// return room number
int Room::getRoomNumber()
{
return roomNumber;
}
// set room status
void Room::setStatus(std::string rmStatus)
{
status = rmStatus;
}
// return room status
string Room::getStatus()
{
return status;
}
// return total cost of room, including extras
int Room::getTotalCost()
{
return totalRoomCost;
}
// set number of nights guest will be staying at hotel
void Room::setDuration()
{
durationFlag:
cout << "How many nights will you be staying? (Maximum is 7 nights) ";
getline(cin, duration);
// check if duration input has spaces, or is empty
if (stringHasSpace(duration))
{
goto durationFlag;
}
else if (duration.length() > 1)
{
cout << "*** ERROR: Invalid input. Try again. ***" << endl;
goto durationFlag;
}
// duration cannot be more than 7 nights
if (stoi(duration) > 7)
{
cout << "Duration exceeds limit of 7 nights. Enter again." << endl;
goto durationFlag;
}
}
// room destructor
Room::~Room()
{
cout << "Room destructor called" << endl;
}
// single room constructor
singleRoom::singleRoom()
{
roomType = 's';
roomNumber = 0;
status = "VACANT";
totalRoomCost = 0;
singleExtrasCost = 5;
singleRoomCost = 50; // per night'
cout << "Single constructor called" << endl;
}
// set single room cost
void singleRoom::setTotalCost()
{
singleExtra: // flag
string wantExtra;
// ask user if they want to get extra
cout << "Would you like to add a snack basket for an additional price of $" << singleExtrasCost << " ?" << endl;
cout << "(y/n) ";
getline(cin, wantExtra);
// validate user input
if (!validateYesNo(wantExtra))
{
goto singleExtra;
}
// calculate total cost of room with/without extras
if (wantExtra == "y")
{
totalRoomCost = singleExtrasCost + (singleRoomCost * stoi(duration));
}
else
{
totalRoomCost = singleRoomCost*(stoi(duration));
}
}
// single room destructor
singleRoom::~singleRoom()
{
cout << "Called single destructor" << endl;
}
// double room constructor
doubleRoom::doubleRoom()
{
roomType = 'd';
roomNumber = 0;
status = "VACANT";
totalRoomCost = 0;
doubleExtrasCost = 10;
doubleRoomCost = 100; // per night
cout << "Double constructor called" << endl;
}
// set double room cost
void doubleRoom::setTotalCost()
{
doubleExtra:
string wantExtra;
cout << "Would you like to add an in-room cocktail station for an additional price of $" << doubleExtrasCost << " ?" << endl;
cout << "(y/n) ";
getline(cin, wantExtra);
if (!validateYesNo(wantExtra))
{
goto doubleExtra;
}
if (wantExtra == "y")
{
totalRoomCost = doubleExtrasCost + (doubleRoomCost * stoi(duration));
}
else
{
totalRoomCost = doubleRoomCost * stoi(duration);
}
}
// double room destructor
doubleRoom::~doubleRoom()
{
cout << "Called double destructor" << endl;
}
// grand room constructor
grandRoom::grandRoom()
{
roomType = 'g';
roomNumber = 0;
status = "VACANT";
totalRoomCost = 0;
grandExtrasCost = 20;
grandRoomCost = 150; // per night
cout << "Grand contructor called" << endl;
}
// set grand room cost
void grandRoom::setTotalCost()
{
grandExtra:
string wantExtra;
cout << "Would you like to add a family game pack for an additional price of $" << grandExtrasCost << " ?" << endl;
cout << "(y/n) ";
getline(cin, wantExtra);
if (!validateYesNo(wantExtra))
{
goto grandExtra;
}
if (wantExtra == "y")
{
totalRoomCost = grandExtrasCost + (grandRoomCost * stoi(duration));
}
else
{
totalRoomCost = grandRoomCost * stoi(duration);
}
}
// grand room destructor
grandRoom::~grandRoom()
{
cout << "Called grand destructor" << endl;
}