Package com.uca.flights
Class Airport
- java.lang.Object
-
- com.uca.flights.Airport
-
public class Airport extends java.lang.ObjectRepresent an airport
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCity(City city)Add a city to the airport list of served citybooleanequals(java.lang.Object other)Redefinition of equalsAirportIdgetId()GetterCitygetMainCity()Getterjava.lang.StringgetName()Getterjava.util.Collection<City>getServedCity()GetterinthashCode()Redefinition of hashCodevoidremoveCity(City city)Remove a city to the airport list of served cityvoidsetName(java.lang.String name)Setterjava.lang.StringtoString()Redefinition of toString
-
-
-
Constructor Detail
-
Airport
public Airport(City mainCity, java.lang.String id, java.lang.String name)
Constructor- Parameters:
mainCity- the city in which the airport isid- a string used to create the airport idname- 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:
equalsin classjava.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:
hashCodein classjava.lang.Object- Returns:
- the hashcode
-
toString
public java.lang.String toString()
Redefinition of toString- Overrides:
toStringin classjava.lang.Object- Returns:
- a string with name and identifier
-
-