This repository was archived by the owner on Jan 27, 2023. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathAPCNode.cpp
More file actions
146 lines (125 loc) · 4.95 KB
/
Copy pathAPCNode.cpp
File metadata and controls
146 lines (125 loc) · 4.95 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
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
#include "APCNode.h"
#include "Utils.h"
using namespace std;
//-------------------------------------------------------------------------------------------------
// Function Name: APCNode
// Purpose: APCNode default constructor that initializes data members
// Parameters: none
// Returns: none
// Pre-conditions: none
// Post-conditions: none
//-------------------------------------------------------------------------------------------------
APCNode::APCNode()
{
apcKey.clear();
apcOrigin.clear();
apcDestination.clear();
mileage = 0.0;
cost = 0.0;
makeKey();
}
//-------------------------------------------------------------------------------------------------
// Function Name: APCNode
// Purpose: APCNode constructor that allows settig data members from passed parameters
//
// Parameters: string apcOrigin the origin airport code (APC)
// string apcDestination the destination airport code (APC)
// double mileage from the origin to the destination
// double cost from the origin to the destination
//
// Returns: none
// Pre-conditions: none
// Post-conditions: none
//-------------------------------------------------------------------------------------------------
APCNode::APCNode(string apcOrigin, string apcDestination, double mileage, double cost)
{
this->apcOrigin = apcOrigin;
this->apcDestination = apcDestination;
this->mileage = mileage;
this->cost = cost;
makeKey();
}
//-------------------------------------------------------------------------------------------------
// Function Name: ~APCNode
// Purpose: ~APCNode destructor performs house cleaning when node is destroyed
// Parameters: none
// Returns: none
// Pre-conditions: none
// Post-conditions: none
//-------------------------------------------------------------------------------------------------
APCNode::~APCNode()
{
}
//-------------------------------------------------------------------------------------------------
// Function Name: makeKey
// Purpose: makes the key for the node based on apcOrigin and apcDestination
// Parameters: none
// Returns: string containing the key
// Pre-conditions: none
// Post-conditions: none
//-------------------------------------------------------------------------------------------------
string APCNode::makeKey()
{
apcKey = Utils::toLower(apcOrigin) + Utils::toLower(apcDestination);
return getKey();
}
//-------------------------------------------------------------------------------------------------
// Function Name: getKey
// Purpose: get the key (origin+destination) for the node
// Parameters: none
// Returns: string containing the key
// Pre-conditions: the apcKey was already composited
// Post-conditions: none
//-------------------------------------------------------------------------------------------------
string APCNode::getKey() const
{
return apcKey;
}
//-------------------------------------------------------------------------------------------------
// Function Name: getOrigin
// Purpose: get the apcOrigin
// Parameters: none
// Returns: string containing the origin airport code
// Pre-conditions: none
// Post-conditions: none
//-------------------------------------------------------------------------------------------------
string APCNode::getOrigin() const
{
return apcOrigin;
}
//-------------------------------------------------------------------------------------------------
// Function Name: getDestination
// Purpose: get the apcDestination
// Parameters: none
// Returns: string containing the destination airport code
// Pre-conditions: none
// Post-conditions: none
//-------------------------------------------------------------------------------------------------
string APCNode::getDestination() const
{
return apcDestination;
}
//-------------------------------------------------------------------------------------------------
// Function Name: getMileage
// Purpose: get the mileage from the origin to the destination
// Parameters: none
// Returns: double containing the mileage
// Pre-conditions: none
// Post-conditions: none
//-------------------------------------------------------------------------------------------------
double APCNode::getMileage() const
{
return mileage;
}
//-------------------------------------------------------------------------------------------------
// Function Name: getCost
// Purpose: get the cost from the origin to the destination
// Parameters: none
// Returns: double containing the cost
// Pre-conditions: none
// Post-conditions: none
//-------------------------------------------------------------------------------------------------
double APCNode::getCost() const
{
return cost;
}