-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlight.cpp
125 lines (99 loc) · 2.3 KB
/
Flight.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
//
// Created by Sammy Timmins on 10/21/20.
//
#include "Flight.h"
Flight::Flight()
{
time = 0;
price = 0.00;
destination = "";
airline = "";
}
Flight::Flight(const DSString &destination)
{
this->destination = destination;
price = 0.00;
time = 0;
airline = "";
}
Flight::Flight(const DSString &destination, const float price, const int time, const DSString &airline)
{
this->destination = destination;
this->price = price;
this->time = time;
this->airline = airline;
}
Flight::Flight(const Flight ©)
{
destination = copy.destination;
price = copy.price;
time = copy.time;
airline = copy.airline;
}
Flight &Flight::operator=(const Flight ©)
{
destination = copy.destination;
price = copy.price;
time = copy.time;
airline = copy.airline;
return *this;
}
Flight &Flight::operator=(const DSString &location)
{
destination = location;
price = 0.00;
time = 0;
airline = "";
return *this;
}
/**
* compares the destination members of two flights and returns if they are equivalent
*/
bool Flight::operator==(const Flight &toCompare)
{ //all members of the object must be equivalent
return destination == toCompare.destination;
}
int Flight::getTime() const {
return time;
}
float Flight::getPrice() const {
return price;
}
const DSString & Flight::getDest() const {
return destination;
}
const DSString & Flight::getAirline() const {
return airline;
}
void Flight::setTime(const int time)
{
this->time = time;
}
void Flight::setPrice(const float price)
{
this->price = price;
}
void Flight::setDestination(const DSString &destination)
{
this->destination = destination;
}
void Flight::setAirline(const DSString &airline)
{
this->airline = airline;
}
void Flight::setAllZero() //set everything to zero or empty except destination
{
price = 0.00;
time = 0;
airline = "";
}
void Flight::setAll(const float price, const int time, const DSString &airline) //set all values except the destination
{
this->price = price;
this->time = time;
this->airline = airline;
}
bool Flight::checkAllMembers(const Flight &toCheck) {
return (destination == toCheck.destination) && (price == toCheck.price) &&
(time == toCheck.time) && (airline == toCheck.airline);
}