-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathairline_ticket.cpp
More file actions
47 lines (38 loc) · 1.42 KB
/
airline_ticket.cpp
File metadata and controls
47 lines (38 loc) · 1.42 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
module airline_ticket;
using namespace std;
AirlineTicket::AirlineTicket()
: m_passengerName{ "Unknown Passenger" }
, m_numberOfMiles{ 0 }
, m_hasEliteSuperRewardsStatus{ false }
, m_frequentFlyerNumber{std::nullopt}
{
}
AirlineTicket::~AirlineTicket()
{
// Nothing to do in terms of cleanup
}
double AirlineTicket::calculatePriceInDollars() const
{
if (hasEliteSuperRewardsStatus()) {
// Elite Super Rewards customers fly for free!
return 0;
}
// The cost of the ticket is the number of miles times 0.1.
// Real airlines probably have a more complicated formula!
return getNumberOfMiles() * 0.1;
}
const string& AirlineTicket::getPassengerName() const{ return m_passengerName; }
void AirlineTicket::setPassengerName(const string& name) { m_passengerName = name; }
// Other get and set methods have a similar implementation.
int AirlineTicket::getNumberOfMiles() const { return m_numberOfMiles; }
void AirlineTicket::setNumberOfMiles(const int& miles) { m_numberOfMiles = miles; }
bool AirlineTicket::hasEliteSuperRewardsStatus() const { return m_hasEliteSuperRewardsStatus; }
void AirlineTicket::setHasEliteSuperRewardsStatus(bool status) { m_hasEliteSuperRewardsStatus = status; }
const optional<int> AirlineTicket::getFrequentFlyerNumber() const
{
return m_frequentFlyerNumber;
}
void AirlineTicket::setFrequentFlyerNumber(const int& num)
{
m_frequentFlyerNumber = num;
}