Create a FlightManager class This class will store instances
Create a FlightManager class. This class will store instances of the Flight class, and support generating a list of potential itineraries. It should contain 1 constructor, 2 instance variables (an array of Flights, and something that counts the number of flights in the system), and 4 methods (addFlight, increaseSize, findItineraries, shrinkItineraries).
default constructor: will set up the instances variables with zero flights.
addFlight(...): Adds a flight to the flights array. Uses the increaseSize() method if the array is full.
increaseSize(): Doubles the size of the flights array, while keeping whatever is already there. Make this a private method.
findItineraries(...): Searches the flights based on source airport, destination airport, and departure time, to find 1-flight and 2-flight itineraries meeting those criteria. When searching for 2-flight itineraries, checks that the flights have a connecting city, and that the first arrives in time for the second. Your method should create an array of potential itineraries that can be returned. (If it helps, you may assume that this method will never find more than 100 itineraries.) Use the shrinkItineraries() method to \"clean up\" up the potential itineraries array; see below. Hint: use loops to search for all the flights in the flights variable, check if they meet the criteria, and then create a new Itinerary object if the criteria is met.
shrinkItineraries(...). Takes an array of itineraries, where some of the later indices are unused (null), and returns a new array of itineraries where there are no empty indices. Make this a private method.
Solution
The code for the above given is
and please let me know if any errors occurs
public class ItineraryTest
{
public static void main(String[] args)
{
Flight f1 = new Flight(new Plane(Airline.American, \"Airbus A321\"),
\"495\",
79,
new Time(7,10), 100,
Airport.PHX, Airport.LAX);
Flight f2 = new Flight(new Plane(Airline.Delta, \"Boeing 717\"),
\"1063\",
79,
new Time(11, 5),
95,
Airport.LAX,
Airport.SFO);
Itinerary i1 = new Itinerary(f1);
Itinerary i2 = new Itinerary(f1, f2);
System.out.println(i1);
System.out.println();
System.out.println(i2);
}
}

