public class FlightManager
extends Object
Modifier and Type | Field and Description |
---|---|
private AirportManager |
airportManager
Makes the airports available, used by various search methods.
|
private Map<String,Flight> |
flights
Map that holds Flights where the key is the flight number, and the value is
the flight itself
|
Constructor and Description |
---|
FlightManager(AirportManager airportManager)
Creates the FlightManager initialized with an AirportManager.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addFlight(Flight flight)
Adds flight to the map of flights, provided the key doesn't exist, and returns true;
otherwise, returns false.
|
private boolean |
doesMatchDate(LocalDate date,
Flight flight)
Optional, this is a helper method I wrote.
|
private boolean |
doesMatchDestination(String destinationCode,
Flight flight)
Optional, this is a helper method I wrote.
|
private boolean |
doesMatchOrigin(String originCode,
Flight flight)
Optional, this is a helper method I wrote.
|
Flight |
getFlight(String number)
Returns the Flight with the specified flight number
|
List<Flight> |
getFlights()
Returns a list of all flights.
|
List<Flight> |
getFlightsByOrigin(String originCode)
Returns a list of Flights that originate at
originCode (on any date). |
List<Flight> |
getFlightsByOrigin(String originCode,
LocalDate date)
Returns a list of Flights that originate at
originCode on date ,
where date is a String. |
List<Flight> |
getFlightsByOrigin(String originCode,
String date)
Returns a list of Flights that originate at
originCode on date ,
where date is a LocalDate |
List<Flight> |
getFlightsByOriginAndDestination(String originCode,
String destinationCode,
LocalDate date)
Returns a list of Flights between
originCode and destinationCode
that occur on date , where date is a LocalDate |
List<Flight> |
getFlightsByOriginAndDestination(String originCode,
String destinationCode,
String date)
Returns a list of Flights between
originCode and destinationCode
that occur on date , where date is a String |
int |
getNumFlights()
Returns the number of flights.
|
Flight |
removeFlight(Flight flight)
Removes and returns the Flight,
flight |
Flight |
removeFlight(String number)
Removes and returns the Flight with flight number,
number |
private AirportManager airportManager
private Map<String,Flight> flights
public FlightManager(AirportManager airportManager)
airportManager
- public boolean addFlight(Flight flight)
flight
- private boolean doesMatchDate(LocalDate date, Flight flight)
date
- flight
- private boolean doesMatchDestination(String destinationCode, Flight flight)
destinationCode
- flight
- private boolean doesMatchOrigin(String originCode, Flight flight)
originCode
- flight
- public Flight getFlight(String number)
number
- public List<Flight> getFlights()
public List<Flight> getFlightsByOrigin(String originCode)
originCode
(on any date).originCode
- public List<Flight> getFlightsByOrigin(String originCode, LocalDate date)
originCode
on date
,
where date is a String.originCode
- date
- public List<Flight> getFlightsByOrigin(String originCode, String date)
originCode
on date
,
where date is a LocalDateoriginCode
- date
- public List<Flight> getFlightsByOriginAndDestination(String originCode, String destinationCode, LocalDate date)
originCode
and destinationCode
that occur on date
, where date is a LocalDateoriginCode
- destinationCode
- public List<Flight> getFlightsByOriginAndDestination(String originCode, String destinationCode, String date)
originCode
and destinationCode
that occur on date
, where date is a StringoriginCode
- destinationCode
- public int getNumFlights()
public Flight removeFlight(Flight flight)
flight
flight
- The flight to removepublic Flight removeFlight(String number)
number
number
- The flight number of Flight to remove