Package com.uca.flights
Class City
- java.lang.Object
-
- com.uca.flights.City
-
public class City extends java.lang.ObjectRepresent an city
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAirport(Airport airport)Add a airport to the city set of airportbooleanequals(java.lang.Object other)Redefinition of equalsjava.util.Set<Airport>getAirports()GetterCityIdgetCode()Getterjava.lang.StringgetName()GetterinthashCode()Redefinition of hashCodevoidremoveAirport(Airport airport)Remove an airport from the city set of airportvoidsetName(java.lang.String name)Setterjava.lang.StringtoString()Redefinition of toString
-
-
-
Constructor Detail
-
City
public City(CityId code, java.lang.String name)
Constructor- Parameters:
code- a city codename- the city name- Throws:
java.lang.IllegalArgumentException- on null or empty parameter
-
-
Method Detail
-
getName
public java.lang.String getName()
Getter- Returns:
- city name
-
setName
public void setName(java.lang.String name)
Setter- Parameters:
name- the city name- Throws:
java.lang.IllegalArgumentException- on null or empty parameter
-
getCode
public CityId getCode()
Getter- Returns:
- city identifier
-
addAirport
public void addAirport(Airport airport)
Add a airport to the city set of airport- Parameters:
airport- the airport to add, warning on already existing airport- Throws:
java.lang.IllegalArgumentException- on null parameter
-
removeAirport
public void removeAirport(Airport airport)
Remove an airport from the city set of airport- Parameters:
airport- the airport to remove- Throws:
java.lang.IllegalArgumentException- on null, non existing or main city parameter
-
getAirports
public java.util.Set<Airport> getAirports()
Getter- Returns:
- city set of airports
-
toString
public java.lang.String toString()
Redefinition of toString- Overrides:
toStringin classjava.lang.Object- Returns:
- a string with name and identifier
-
equals
public boolean equals(java.lang.Object other)
Redefinition of equals- Overrides:
equalsin classjava.lang.Object- Parameters:
other- the city to compare to- Returns:
- true if other has the same identifier, false else
- Throws:
java.lang.IllegalArgumentException- on null or not city parameter
-
hashCode
public int hashCode()
Redefinition of hashCode- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hashcode
-
-