forked from ashishps1/awesome-low-level-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBooking.cpp
More file actions
48 lines (43 loc) · 2.03 KB
/
Booking.cpp
File metadata and controls
48 lines (43 loc) · 2.03 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
#include "Booking.hpp"
#include <iostream>
#include <iomanip>
Booking::Booking(std::string bookingId, Guest* guest, Room* room,
std::string checkInDate, std::string checkOutDate, int numberOfNights)
: bookingId(bookingId), guest(guest), room(room),
checkInDate(checkInDate), checkOutDate(checkOutDate),
numberOfNights(numberOfNights), status(BookingStatus::CONFIRMED) {
calculateTotalAmount();
}
std::string Booking::getBookingId() const { return bookingId; }
Guest* Booking::getGuest() const { return guest; }
Room* Booking::getRoom() const { return room; }
std::string Booking::getCheckInDate() const { return checkInDate; }
std::string Booking::getCheckOutDate() const { return checkOutDate; }
int Booking::getNumberOfNights() const { return numberOfNights; }
double Booking::getTotalAmount() const { return totalAmount; }
BookingStatus Booking::getStatus() const { return status; }
void Booking::calculateTotalAmount() {
totalAmount = room->getPricePerNight() * numberOfNights;
}
void Booking::setStatus(BookingStatus status) {
this->status = status;
}
void Booking::displayInfo() const {
std::cout << "\nBooking Details:" << std::endl;
std::cout << "Booking ID: " << bookingId << std::endl;
std::cout << "Guest: " << guest->getName() << std::endl;
std::cout << "Room: " << room->getRoomNumber() << std::endl;
std::cout << "Check-in Date: " << checkInDate << std::endl;
std::cout << "Check-out Date: " << checkOutDate << std::endl;
std::cout << "Number of Nights: " << numberOfNights << std::endl;
std::cout << "Total Amount: $" << std::fixed << std::setprecision(2)
<< totalAmount << std::endl;
std::cout << "Status: ";
switch (status) {
case BookingStatus::CONFIRMED: std::cout << "Confirmed"; break;
case BookingStatus::CHECKED_IN: std::cout << "Checked In"; break;
case BookingStatus::CHECKED_OUT: std::cout << "Checked Out"; break;
case BookingStatus::CANCELLED: std::cout << "Cancelled"; break;
}
std::cout << std::endl;
}