Class Airport


  • public class Airport
    extends java.lang.Object
    Airport.java
    Creates a class named Airport that keeps track of the flights that use a certain airport, either as their origin or destination.
    Version:
    1.1 (TM) 09/21/2022
    Author:
    cs230 staff (SK)
    • Constructor Summary

      Constructors 
      Constructor Description
      Airport​(java.lang.String name)
      Constructor for objects of class Airport
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addFlight​(Flight f)
      Adds the given flight to the airport.
      Flight[] findFlightsByAirline​(java.lang.String inputAirline)
      Takes in the name of an airline, and returns all the flights of this airline that use this airport
      int getCapacity()
      Getter for capacity
      int getNumFlights()  
      static void main​(java.lang.String[] args)  
      void printFlightsByAirline​(java.lang.String inputAirline)
      Takes in the name of an airline, and prints all its flights that use this airport
      java.lang.String toString()
      Returns a String representation of this airport
      • Methods inherited from class java.lang.Object

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

      • Airport

        public Airport​(java.lang.String name)
        Constructor for objects of class Airport
    • Method Detail

      • 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 cannot accommodate any more flights, a suitable message is presented, and the flight is not added.
        Parameters:
        f - A new flight to be added to this airport
      • getCapacity

        public int getCapacity()
        Getter for capacity
        Returns:
        the capacity of the airport: how many flights it can accommodate
      • getNumFlights

        public int getNumFlights()
        Returns:
        the number of flights currently using the airport
      • toString

        public java.lang.String toString()
        Returns a String representation of this airport
        Overrides:
        toString in class java.lang.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​(java.lang.String inputAirline)
        Takes in the name of an airline, and returns all the flights of this airline that use this airport
        Parameters:
        inputAirline - 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​(java.lang.String inputAirline)
        Takes in the name of an airline, and prints all its flights that use this airport
        Parameters:
        inputAirline - the name of the airline of interest
      • main

        public static void main​(java.lang.String[] args)