-
Notifications
You must be signed in to change notification settings - Fork 1
/
Airport.java
148 lines (122 loc) · 3.63 KB
/
Airport.java
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
import java.util.ArrayList;
import java.util.HashMap;
public class Airport {
// ----- INSTANCE VARIABLES ------
private String airportName;
private String airportID;
private String airportCode;
private City cityOfAirport;
private Airport sourceAirport;
private Airline sourceAirportAirline;
private ArrayList <Airline> destinationAirportAirlines = new ArrayList<>();
HashMap<String, Airline> destinationAirportsAirlinesHm = new HashMap<>();
// private ArrayList <Airport> destinationAirports = new ArrayList<>();
HashMap <String, Airport> destinationAirportsHm = new HashMap<>();
// ----- CONSTRUCTORS ------
public Airport(String airportID, String airportName, City cityOfAirport) {
this.airportID = airportID;
this.airportName = airportName;
this.cityOfAirport = cityOfAirport;
}
public Airport(String airportID) {
this.airportID = airportID;
}
public Airport(String airportID, String airportCode) {
this.airportID = airportID;
this.airportCode = airportCode;
}
// ----- INSTANCE METHODS ------
/**
* @return name of Airport
*/
public String getAirportName() {
return airportName;
}
/**
* set name of airport to airportName
* @param airportName
*/
public void setAirportName(String airportName) {
this.airportName = airportName;
}
/**
* @return ID of the airport
*/
public String getAirportID() {
return airportID;
}
/**
* set ID of airport to airportID
* @param airportID
*/
public void setAirportID(String airportID) {
this.airportID = airportID;
}
/**
* @return code of airport
*/
public String getAirportCode() {
return airportCode;
}
/**
* set code of airport to airportCode
* @param airportCode
*/
public void setAirportCode(String airportCode) {
this.airportCode = airportCode;
}
/**
* @return city object the airport is in
*/
public City getCityOfAirport() {
return cityOfAirport;
}
/**
* set city airport is in to cityOfAirport
* @param cityOfAirport
*/
public void setCityOfAirport(City cityOfAirport) {
this.cityOfAirport = cityOfAirport;
}
/**
* @return the source airport
*/
public Airport getSourceAirport() {
return sourceAirport;
}
/**
* set source airport to sourceAirport
* @param sourceAirport
*/
public void setSourceAirport(Airport sourceAirport) {
this.sourceAirport = sourceAirport;
}
/**
* @return the airline used to fly from source airport to current airport
*/
public Airline getSourceAirportAirline() {
return sourceAirportAirline;
}
/**
* set airline used to fly from source airport to sourceAirportAirline
* @param sourceAirportAirline
*/
public void setSourceAirportAirline(Airline sourceAirportAirline) {
this.sourceAirportAirline = sourceAirportAirline;
}
/**
* @return airlines used to fly to various destination airports.
*/
public ArrayList<Airline> getDestinationAirportAirlines() {
return destinationAirportAirlines;
}
public void addToDestinationAirportAirlines(Airline airline) {
destinationAirportAirlines.add(airline);
}
/**
* @return string version of airport: Airport id, Airport Name, and City Name
*/
public String toString () {
return "(" + getAirportID() + ", " + getAirportName() + ", " + getCityOfAirport().getCityName() + ")";
}
}