public class AirportManager
extends Object
Modifier and Type | Field and Description |
---|---|
private Map<String,Airport> |
airports
A map of Airports where the airport code is the key and the value is an Airport.
|
Constructor and Description |
---|
AirportManager(Map<String,Airport> airports)
Creates the AirportManager with a map of airports.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addAirport(Airport airport)
Adds an airport to the AirportManager
|
boolean |
containsAirport(String code)
Returns true if code is a valid airport code, false otherwise
|
Airport |
getAirport(String code)
Returns the airport with specified code if it exists
|
private Airport |
getAirportClosestTo(List<Airport> airports,
String code)
This is a helper method I wrote.
|
Airport |
getAirportClosestTo(String code)
Returns the Airport closest in distance (miles) to the airport specified by the input code
|
Airport |
getAirportClosestTo2(String code)
Returns the Airport closest in distance (miles) to the airport specified by the input code,
different implementation of getAirportClosestTo
|
List<String> |
getAirportCodes()
Returns a sorted list of airport codes.
|
List<Airport> |
getAirports()
Returns a list of all airports
|
List<Airport> |
getAirportsByCity(String city)
Returns a list of the Airports whose “City” begins with "city", i.e.
|
List<Airport> |
getAirportsByCityState(String city,
String state)
Returns a list of the Airports whose “City” is city and “State” is state.
|
List<Airport> |
getAirportsClosestTo(String code,
int num)
Returns a list of the
num Airports that are closest in distance (miles) to the Airport with |
List<Airport> |
getAirportsSortedBy(String sortType)
Returns a list of Airports that are sorted according to sortType.
|
List<Airport> |
getAirportsWithin(double withinDist,
double lat,
double lon)
Returns a list of Airports within a distance, withinDist, of the
input latitude & longitude.
|
List<Airport> |
getAirportsWithin(String code,
double withinDist)
Returns a list of Airports within a distance, withinDist, of the
airport specified by its code.
|
List<Airport> |
getAirportsWithin(String code1,
String code2,
double withinDist)
Returns a list of Airports which are within withinDist of both the
Airports that correspond to code1 and code2.
|
double |
getDistanceBetween(Airport airport1,
Airport airport2)
Returns the distance between two airports.
|
double |
getDistanceBetween(String code1,
String code2)
Returns the distance between two airports as specified by their codes.
|
int |
getNumAirports()
Returns the number of airports.
|
List<Airport> |
getNWSNamedAirports()
Returns a list of the Airports whose code follows the National Weather Service (NWS)
naming system.
|
Airport |
removeAirport(String code)
Removes an airport from the AirportManager
|
private Map<String,Airport> airports
public AirportManager(Map<String,Airport> airports)
airports
- public boolean addAirport(Airport airport)
airport
- public boolean containsAirport(String code)
code
- - Airport codepublic Airport getAirport(String code)
code
- private Airport getAirportClosestTo(List<Airport> airports, String code)
airports
- code
- public Airport getAirportClosestTo(String code)
code
- public Airport getAirportClosestTo2(String code)
code
- public List<String> getAirportCodes()
public List<Airport> getAirports()
public List<Airport> getAirportsByCity(String city)
city
- public List<Airport> getAirportsByCityState(String city, String state)
city
- state
- public List<Airport> getAirportsClosestTo(String code, int num)
num
Airports that are closest in distance (miles) to the Airport with code
- num
- public List<Airport> getAirportsSortedBy(String sortType)
sortType
- public List<Airport> getAirportsWithin(double withinDist, double lat, double lon)
withinDist
- lat
- lon
- public List<Airport> getAirportsWithin(String code, double withinDist)
code
- withinDist
- public List<Airport> getAirportsWithin(String code1, String code2, double withinDist)
code1
- code2
- withinDist
- public double getDistanceBetween(Airport airport1, Airport airport2)
airport1
- airport2
- public double getDistanceBetween(String code1, String code2)
code1
- code2
- public int getNumAirports()
public List<Airport> getNWSNamedAirports()
public Airport removeAirport(String code)
code
- Code of airport to remove