-
Notifications
You must be signed in to change notification settings - Fork 0
/
BookingManager.cpp
48 lines (40 loc) · 1.29 KB
/
BookingManager.cpp
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
#ifndef BOOKINGMANAGER
#define BOOKINGMANAGER
#include <memory>
#include "Ticket.cpp"
#include "./show/IShow.h"
#include "Theater.cpp"
#include "./payment/Payment.h"
#include "./payment/PaymentManager.cpp"
using namespace std;
class BookingManager
{
private:
shared_ptr<Ticket> ticket;
shared_ptr<IShow> show;
public:
BookingManager(int ticketId, shared_ptr<Theater> theater, shared_ptr<IShow> show)
{
ticket = shared_ptr<Ticket>(new Ticket(ticketId,show->getShowId(),
show->getMovie().getMovieName(), show->getShowTime(), show->getScreenHall()->getScreenHallId()));
ticket->setTheaterDetails(theater->getTheaterId(), theater->getTheaterName(), theater->getTheaterAddress());
this->show = show;
}
BookingManager& reservedSeats(string rowId, vector<int> seats)
{
vector<shared_ptr<Seat>> resSeats = show->reserveSeats(rowId, seats);
ticket->setReservedSeats(resSeats);
return *this;
}
BookingManager& addCustomerData(string fullname, string mobile) {
ticket->setCustomerData(fullname, mobile);
return *this;
}
shared_ptr<Ticket> PayAndBook(shared_ptr<Payment> paymentStrategy) {
double ticketAmount = ticket->calculateTotalBookingAmount();
PaymentManager payManager(paymentStrategy);
payManager.makePayment(ticketAmount);
return ticket;
}
};
#endif // !BOOKINGMANAGER