Repository navigation
Expand file tree
/
Copy pathReservation.cpp
More file actions
267 lines (221 loc) · 6.58 KB
/
Copy pathReservation.cpp
File metadata and controls
267 lines (221 loc) · 6.58 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#include "Reservation.h"
Reservation::Reservation()
{
reservationID = 0; //Each Reservation has a unique reservation ID
guestID = 0; //Each guest has a unique guest ID
roomID = 0; //Each room has a unique room ID
checkInDate = "0000-00-00"; //Date that guest wants to check into room
checkOutDate = "0000-00-00"; //Date that guest wants to check out of room
numberOfGuests = 0; //Number of guests for the reservation
reservationDate = "0000-00-00"; //Date that reservation was made
status = "None"; //Status of the Reservation ("See method for status details")
totalPrice = 0; //Total price for the reservation
paymentStatus = "None"; //Status of the payment
specialRequests = "None"; //Requests that guest wants to make for their reservation
specialDiscount = Discount(0.0,"No Discount"); //Special Discount that guest may qualify for
}
void Reservation::setReservationID(int resID)
{
reservationID = resID;
}
void Reservation::setGuestID(int gID)
{
guestID = gID;
}
void Reservation::setRoomID(int rID)
{
roomID = rID;
}
/*
* Date Format: YYYYMMDD
* Example: August 25, 2025 --> 20250825
* Date Formated: 2025-08-25
*/
void Reservation::setCheckInDate(int date)
{
string sDate = std::to_string(date); // "20251110"
checkInDate = sDate.substr(0, 4) + "-" + sDate.substr(4, 2) + "-" + sDate.substr(6, 2);
}
/*
* Date Format: YYYYMMDD
* Example: August 25, 2025 --> 20250825
* Date Formated: 2025-08-25
*/
void Reservation::setCheckOutDate(int date)
{
string sDate = std::to_string(date); // "20251110"
checkOutDate = sDate.substr(0, 4) + "-" + sDate.substr(4, 2) + "-" + sDate.substr(6, 2);
}
void Reservation::setNumberOfGuests(int guestsNum)
{
numberOfGuests = guestsNum;
}
/*
* Date Format: YYYYMMDD
* Example: August 25, 2025 --> 20250825
* Date Formated: 2025-08-25
*/
void Reservation::setReservationDate(int date)
{
string sDate = std::to_string(date); // "20251110"
reservationDate = sDate.substr(0, 4) + "-" + sDate.substr(4, 2) + "-" + sDate.substr(6, 2);
}
/*
* Statuses include:
* - “Booked”
* - “Cancelled”
* - “Pending Booking”
* - “No Reservation” (Default)
*/
void Reservation::setStatus(string newStatus)
{
status = newStatus;
}
void Reservation::setTotalPrice(int price)
{
totalPrice = price;
}
/*
* Statuses include:
* - “Payment Received”
* - “Pending Payment”
* - “No Payment” (Default)
*/
void Reservation::setPaymentStatus(string newStatus)
{
paymentStatus = newStatus;
}
void Reservation::setSpecialRequests(string newRequest)
{
specialRequests = newRequest;
}
void Reservation::setSpecialDiscount(Discount discount)
{
specialDiscount = discount;
}
int Reservation::getReservationID() const
{
return reservationID;
}
int Reservation::getGuestID() const
{
return guestID;
}
int Reservation::getRoomID() const
{
return roomID;
}
string Reservation::getCheckInDate() const
{
return checkInDate;
}
string Reservation::getCheckOutDate() const
{
return checkOutDate;
}
int Reservation::getNumberOfGuests() const
{
return numberOfGuests;
}
string Reservation::getReservationDate() const
{
return reservationDate;
}
string Reservation::getStatus() const
{
return status;
}
int Reservation::getTotalPrice() const
{
return totalPrice;
}
string Reservation::getPaymentStatus() const
{
return paymentStatus;
}
string Reservation::getSpecialRequests() const
{
return specialRequests;
}
Discount Reservation::getSpecialDiscount() const
{
return specialDiscount;
}
/*
* This method adds all needed information into a reservation object.
*/
void Reservation::makeReservation(int resID, int gID, int rID, int chInDate, int chOutDate, int guestCount, int resDate, string sRequests, Discount discount)
{
setReservationID(resID);
setGuestID(gID);
setRoomID(rID);
setCheckInDate(chInDate);
setCheckOutDate(chOutDate);
setNumberOfGuests(guestCount);
setReservationDate(resDate);
setTotalPrice(-1);
setStatus("Pending Booking");
setPaymentStatus("No Payment");
setSpecialRequests(sRequests);
setSpecialDiscount(discount);
}
/*
* This method will be used to modify or update a reservation.
* ReservationID cannot be updated.
*/
void Reservation::updateReservation(int gID, int rID, int chInDate, int chOutDate, int guestCount, int resDate, string sRequests, Discount discount)
{
setGuestID(gID);
setRoomID(rID);
setCheckInDate(chInDate);
setCheckOutDate(chOutDate);
setNumberOfGuests(guestCount);
setReservationDate(resDate);
setSpecialRequests(sRequests);
setSpecialDiscount(discount);
}
/*
* This method will set reservation as cancelled. But will keep reservation information intact
*/
void Reservation::cancelReservation()
{
status = "Cancelled";
}
/*
* This method will return a receipt that includes all the information about this reservation.
* Using string stream to make string apending easier
*/
string Reservation::getReceipt() const
{
string receipt;
stringstream streamReceipt;
const int LABEL_WIDTH = 20;
streamReceipt << left << setw(LABEL_WIDTH) << "Reservation ID:"
<< right << getReservationID() << endl;
streamReceipt << left << setw(LABEL_WIDTH) << "Guest ID:"
<< right << getGuestID() << endl;
streamReceipt << left << setw(LABEL_WIDTH) << "Room ID:"
<< right << getRoomID() << endl;
streamReceipt << left << setw(LABEL_WIDTH) << "Check-In-Date:"
<< right << getCheckInDate() << endl;
streamReceipt << left << setw(LABEL_WIDTH) << "Check-Out-Date:"
<< right << getCheckOutDate() << endl;
streamReceipt << left << setw(LABEL_WIDTH) << "Number of Guests:"
<< right << getNumberOfGuests() << endl;
streamReceipt << left << setw(LABEL_WIDTH) << "Reservation Date:"
<< right << getReservationDate() << endl;
streamReceipt << left << setw(LABEL_WIDTH) << "Status:"
<< right << getStatus() << endl;
streamReceipt << left << setw(LABEL_WIDTH) << "Total Price:"
<< right << "$" << getTotalPrice() << endl;
streamReceipt << left << setw(LABEL_WIDTH) << "Payment Status:"
<< right << getPaymentStatus() << endl;
streamReceipt << left << setw(LABEL_WIDTH) << "Special Requests:" << endl;
streamReceipt << " " << getSpecialRequests() << endl;
streamReceipt << left << setw(LABEL_WIDTH) << "Discount Applied:"
<< right << getSpecialDiscount().getDiscountName() <<
" - " << (getSpecialDiscount().getDiscountRate() * 100) << "%" << endl;
streamReceipt << endl;
receipt = streamReceipt.str();
return receipt;
}