Class Airport


public class Airport extends Object
Airport.java
Airport class maintains a collection of Flights that use this airport.
Version:
Sep 30, 2024
Author:
cs230 staff (YY)
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for objects of class Airport
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addFlight(Flight f)
    Adds the given flight to the airport.
    Flight[]
    Takes in the name of an airline, and returns all the flights of this airline that use this airport
    static void
    main(String[] args)
     
    void
    Takes in the name of an airline, and prints all its flights that use this airport
    Returns a String representation of this airport

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Airport

      public Airport(String name)
      Constructor for objects of class Airport
  • Method Details

    • addFlight

      public void addFlight(Flight f)
      Adds the given flight to the airport. Assumes this flight has not already been using this airport, (ie it is not already in the array). If the airport reaches capacity, increase its capacity to accommodate more flights.
      Parameters:
      f - A new flight to be added to this airport
    • toString

      public String toString()
      Returns a String representation of this airport
      Overrides:
      toString in class Object
      Returns:
      a String representation of this airport, containing its capacity, the number of flights it currently serves, as well as those flights.
    • findFlightsByAirline

      public Flight[] findFlightsByAirline(String inputAirline)
      Takes in the name of an airline, and returns all the flights of this airline that use this airport
      Parameters:
      the - name of the airline of interest
      Returns:
      an array containing all flights of the given airline that use this airport
    • printFlightsByAirline

      public void printFlightsByAirline(String inputAirline)
      Takes in the name of an airline, and prints all its flights that use this airport
      Parameters:
      the - name of the airline of interest
    • main

      public static void main(String[] args)