-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseat.cpp
143 lines (108 loc) · 4.11 KB
/
seat.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
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
#include "seat.h"
//------------------CONST NUMBERS---------------
const int GREEN_ROOM_PRICE = 0;
const int MAIN_HALL_PRICE = 100;
const int SPECIAL_PRICE = 300;
const int GOLDEN_CIRCLE_PRICE = 1000;
const int DISABLE_PODIUM_PRICE = 200;
const int FRONT_REGULAR_PRICE = 500;
const int MIDDLE_REGULAR_PRICE = 250;
// ---------------------------------------------
NoPrice::NoPrice(const string &message) : m_message(message) {}
const char* NoPrice::what() const noexcept {
return m_message.c_str();
}
// ---------------------------------------------
Seat::Seat(int line, int chair, int base_price) :
m_line(line), m_chair(chair) {
// check valid price is given
if (base_price < 0)
m_price = 0;
else m_price = base_price;
}
int Seat::price() const {
return m_price;
}
string Seat::location() const {
string line("line: ");
string row_number = to_string(m_line);
string chair(", chair: ");
string seat_number = to_string(m_chair);
return line + row_number + chair + seat_number;
}
// ---------------------------------------------
GreenRoomSeat::GreenRoomSeat(int line, int chair) :
Seat(line, chair, GREEN_ROOM_PRICE) {}
int GreenRoomSeat::price() const {
// GreenRoomSeat doesn't have a price
throw NoPrice("Not For Sale !");
}
string GreenRoomSeat::location() const {
return "Green Room-> " + Seat::location();
}
// ---------------------------------------------
MainHallSeat::MainHallSeat(int line, int chair, int price) :
Seat(line, chair, price) {}
int MainHallSeat::price() const {
return Seat::price() + MAIN_HALL_PRICE;
}
// ---------------------------------------------
SpecialSeat::SpecialSeat(int line , int chair, int price) :
MainHallSeat(line, chair, price) {}
int SpecialSeat::price() const {
return MainHallSeat::price() + SPECIAL_PRICE;
}
// ---------------------------------------------
GoldenCircleSeat::GoldenCircleSeat(int line, int chair, int price) :
SpecialSeat(line, chair, price) {}
string GoldenCircleSeat::location() const {
return "Golden Circle-> " + Seat::location();
}
int GoldenCircleSeat::price() const {
return SpecialSeat::price() + GOLDEN_CIRCLE_PRICE;
}
// ---------------------------------------------
DisablePodiumSeat::DisablePodiumSeat(int line, int chair, int price) :
SpecialSeat(line, chair, price) {}
string DisablePodiumSeat::location() const {
return "Disable Podium-> " + Seat::location();
}
int DisablePodiumSeat::price() const {
return DISABLE_PODIUM_PRICE;
}
// ---------------------------------------------
RegularSeat::RegularSeat(char area, int line, int chair, int price) :
MainHallSeat(line, chair, price), m_area(area) {}
string RegularSeat::location() const {
string area = "area: ";
area += m_area;
return area + ", " + Seat::location();
}
// ---------------------------------------------
FrontRegularSeat::FrontRegularSeat(char area, int line, int chair, int price) :
RegularSeat(area, line, chair, price) {}
int FrontRegularSeat::price() const {
return MainHallSeat::price() + FRONT_REGULAR_PRICE;
}
string FrontRegularSeat::location() const {
return "Front-> " + RegularSeat::location();
}
// ---------------------------------------------
MiddleRegularSeat::MiddleRegularSeat(char area, int line, int chair, int price) :
RegularSeat(area, line, chair, price) {}
int MiddleRegularSeat::price() const {
return MainHallSeat::price() + MIDDLE_REGULAR_PRICE;
}
string MiddleRegularSeat::location() const {
return "Middle-> " + RegularSeat::location();
}
// ---------------------------------------------
RearRegularSeat::RearRegularSeat(char area, int line, int chair, int price) :
RegularSeat(area, line, chair, price) {}
string RearRegularSeat::location() const {
return "Rear-> " + RegularSeat::location();
}
int RearRegularSeat::price() const {
return MainHallSeat::price();
}
// ---------------------------------------------