This repository has been archived by the owner on Oct 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathseat.h
166 lines (152 loc) · 3.77 KB
/
seat.h
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
#ifndef HW3_SEAT_H
#define HW3_SEAT_H
#include <iostream>
#include <string>
#include <stdexcept>
using std::string;
using std::exception;
using std::runtime_error;
// ---------------------------------------------
class NoPrice : public runtime_error
{
public:
NoPrice();
};
// ---------------------------------------------
/**
* abstract class
*/
class Seat
{
int line;
int chair;
int base_price;
protected:
/**
* get the location string format by given params
* @param class_name
* @param area
* @return string as described in the PDF.
*/
string getLocation(const string class_name, char area = 0) const;
public:
Seat(int line, int chair, int basePrice);
virtual ~Seat()= default;
/**
* @return the location string of the class
*/
virtual string location() const =0;
/**
* @return class price(int)
*/
virtual int price() const;
};
// ---------------------------------------------
/**
* inherit from Seat, not containe price
*/
class GreenRoomSeat : public Seat
{
public:
GreenRoomSeat(int line, int chair);
~GreenRoomSeat() override = default;
string location() const override;
/**
* this function will throw NoPrice exeption
*/
int price() const override;
};
// ---------------------------------------------
/**
* abstract class
* inherit from Seat, price is increase the basic price by 100
*/
class MainHallSeat : public Seat
{
protected:
MainHallSeat(int line, int chair, int basePrice);
public:
virtual ~MainHallSeat() override = default;
};
// ---------------------------------------------
/**
* abstract class
* inherit from MainHallSeat, price is increase the basic price by 300
*/
class SpecialSeat : public MainHallSeat
{
protected:
SpecialSeat(int line, int chair, int basePrice);
public:
virtual ~SpecialSeat() override = default;
};
// ---------------------------------------------
/**
* inherit from SpecialSeat, price is increase the basic price by 1000
*/
class GoldenCircleSeat : public SpecialSeat
{
public:
GoldenCircleSeat(int line, int chair, int basePrice);
~GoldenCircleSeat() override = default;
string location() const override;
};
// ---------------------------------------------
/**
* inherit from SpecialSeat, price is 200
*/
class DisablePodiumSeat : public SpecialSeat
{
public:
DisablePodiumSeat(int line, int chair, int basePrice=0);
~DisablePodiumSeat() override = default;
string location() const override;
};
// ---------------------------------------------
/**
* abstract class
* inherit from SpecialSeat
*/
class RegularSeat : public MainHallSeat
{
protected:
char area;
RegularSeat(char area, int line, int chair, int basePrice);
public:
virtual ~RegularSeat() override = default;
};
// ---------------------------------------------
/**
* inherit from RegularSeat, price is increase the basic price by 500
*/
class FrontRegularSeat : public RegularSeat
{
public:
FrontRegularSeat(char area, int line, int chair, int basePrice);
~FrontRegularSeat() override = default;
string location() const override;
};
// ---------------------------------------------
/**
* inherit from RegularSeat, price is increase the basic price by 250
*/
class MiddleRegularSeat : public RegularSeat
{
public:
MiddleRegularSeat(char area, int line, int chair, int basePrice);
~MiddleRegularSeat() override = default;
string location() const override;
};
// ----------------------------------ֺֺ-----------
/**
* inherit from RegularSeat
*/
class RearRegularSeat : public RegularSeat
{
public:
RearRegularSeat(char area, int line, int chair, int basePrice);
~RearRegularSeat() override = default;
string location() const override;
};
// ---------------------------------------------
#endif //HW3_SEAT_H