Class Airport


  • public class Airport
    extends java.lang.Object
    Represent an airport
    • Constructor Summary

      Constructors 
      Constructor Description
      Airport​(City mainCity, AirportId id, java.lang.String name)
      Constructor
      Airport​(City mainCity, java.lang.String id, java.lang.String name)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCity​(City city)
      Add a city to the airport list of served city
      boolean equals​(java.lang.Object other)
      Redefinition of equals
      AirportId getId()
      Getter
      City getMainCity()
      Getter
      java.lang.String getName()
      Getter
      java.util.Collection<City> getServedCity()
      Getter
      int hashCode()
      Redefinition of hashCode
      void removeCity​(City city)
      Remove a city to the airport list of served city
      void setName​(java.lang.String name)
      Setter
      java.lang.String toString()
      Redefinition of toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Airport

        public Airport​(City mainCity,
                       java.lang.String id,
                       java.lang.String name)
        Constructor
        Parameters:
        mainCity - the city in which the airport is
        id - a string used to create the airport id
        name - the airport name
        Throws:
        java.lang.IllegalArgumentException - on null or empty parameter
      • Airport

        public Airport​(City mainCity,
                       AirportId id,
                       java.lang.String name)
        Constructor
        Parameters:
        mainCity - the city in which the airport is
        id - the airport identifier
        name - the airport name
        Throws:
        java.lang.IllegalArgumentException - on null or empty parameter
    • Method Detail

      • getName

        public java.lang.String getName()
        Getter
        Returns:
        airport name
      • getMainCity

        public City getMainCity()
        Getter
        Returns:
        airport main city
      • setName

        public void setName​(java.lang.String name)
        Setter
        Parameters:
        name - the airport name
        Throws:
        java.lang.IllegalArgumentException - on null or empty parameter
      • getId

        public AirportId getId()
        Getter
        Returns:
        airport id
      • getServedCity

        public java.util.Collection<City> getServedCity()
        Getter
        Returns:
        a shallow copy of the airport list of served city
      • addCity

        public void addCity​(City city)
        Add a city to the airport list of served city
        Parameters:
        city - the city to add, warning on already existing city
        Throws:
        java.lang.IllegalArgumentException - on null parameter
      • removeCity

        public void removeCity​(City city)
        Remove a city to the airport list of served city
        Parameters:
        city - the city to remove
        Throws:
        java.lang.IllegalArgumentException - on null, inextistant or mainCity parameter
      • equals

        public boolean equals​(java.lang.Object other)
        Redefinition of equals
        Overrides:
        equals in class java.lang.Object
        Parameters:
        other - the airport to compare to
        Returns:
        true if other has the same identifier, false else
        Throws:
        java.lang.IllegalArgumentException - on null or not airport parameter
      • hashCode

        public int hashCode()
        Redefinition of hashCode
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashcode
      • toString

        public java.lang.String toString()
        Redefinition of toString
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string with name and identifier