Package com.uca.flights
Class Company
- java.lang.Object
-
- com.uca.flights.Company
-
public class Company extends java.lang.ObjectRepresent a flight company
-
-
Constructor Summary
Constructors Constructor Description Company(java.lang.String prefix, java.lang.String name)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFlight(java.time.ZonedDateTime departure, Trip trip)Create and add a flightvoidaddFlight(java.time.ZonedDateTime departure, TripBuilder trip)Create and add a flightvoidaddRegularFlight(java.time.ZonedDateTime departure, int i)Create and add a regular flight from the registryvoidaddRegulars(java.util.ArrayList<Trip> t)Add several regular tripvoidclose(FlightId id)Close a flight to reservationFlightgetFlight(FlightId id)Getterjava.util.ArrayList<FlightId>getFlights()Getterjava.lang.StringgetName()Getterjava.util.ArrayList<Trip>getRegulars()Gettervoidopen(FlightId id)Open a flight to reservationvoidregularize(FlightId id)Regularize a flight : make a copy of the trip in the registryvoidremoveFlight(FlightId id)Remove a flightvoidremoveRegular(int i)Remove a regular from the registryvoidremoveRegular(Trip t)Remove a regular from the registryvoidsetName(java.lang.String name)SettervoidsetRegulars(java.util.ArrayList<Trip> t)Setterjava.lang.StringtoString()Redefinition of toString
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Getter- Returns:
- the company name
-
setName
public void setName(java.lang.String name)
Setter- Parameters:
name- the company name- Throws:
java.lang.IllegalArgumentException- on null or empty parameter
-
getFlights
public java.util.ArrayList<FlightId> getFlights()
Getter- Returns:
- the company flight ids
-
getFlight
public Flight getFlight(FlightId id)
Getter- Parameters:
id- the flight id- Returns:
- the flight associated
- Throws:
java.lang.IllegalArgumentException- on null parameter
-
addFlight
public void addFlight(java.time.ZonedDateTime departure, TripBuilder trip)Create and add a flight- Parameters:
trip- the flight trip as a tripbuilderdeparture- the flight departure date- Throws:
java.lang.IllegalArgumentException- on null parameter
-
addFlight
public void addFlight(java.time.ZonedDateTime departure, Trip trip)Create and add a flight- Parameters:
trip- the flight tripdeparture- the flight departure date- Throws:
java.lang.IllegalArgumentException- on null parameter
-
addRegularFlight
public void addRegularFlight(java.time.ZonedDateTime departure, int i)Create and add a regular flight from the registry- Parameters:
i- regular flight index in the registrydeparture- the flight departure date- Throws:
java.lang.IllegalArgumentException- on null parameter or negative index
-
removeFlight
public void removeFlight(FlightId id)
Remove a flight- Parameters:
id- the flight id- Throws:
java.lang.IllegalArgumentException- on null or non existent parameter
-
open
public void open(FlightId id)
Open a flight to reservation- Parameters:
id- the flight id- Throws:
java.lang.IllegalArgumentException- on null or non existent parameter
-
close
public void close(FlightId id)
Close a flight to reservation- Parameters:
id- the flight id- Throws:
java.lang.IllegalArgumentException- on null or non existent parameter
-
regularize
public void regularize(FlightId id)
Regularize a flight : make a copy of the trip in the registry- Parameters:
id- the flight id- Throws:
java.lang.IllegalArgumentException- on null or non existent parameter
-
getRegulars
public java.util.ArrayList<Trip> getRegulars()
Getter- Returns:
- a shallow copy of the list of regular trip
-
removeRegular
public void removeRegular(int i) throws java.lang.IllegalArgumentExceptionRemove a regular from the registry- Parameters:
i- regular flight index in the registry- Throws:
java.lang.IllegalArgumentException- on negative index
-
removeRegular
public void removeRegular(Trip t) throws java.lang.IllegalArgumentException
Remove a regular from the registry- Parameters:
t- the regular trip- Throws:
java.lang.IllegalArgumentException- null or non existent parameter
-
setRegulars
public void setRegulars(java.util.ArrayList<Trip> t)
Setter- Parameters:
t- the regular trip list- Throws:
java.lang.IllegalArgumentException- null parameter
-
addRegulars
public void addRegulars(java.util.ArrayList<Trip> t)
Add several regular trip- Parameters:
t- a list of trip- Throws:
java.lang.IllegalArgumentException- on null parameter
-
toString
public java.lang.String toString()
Redefinition of toString- Overrides:
toStringin classjava.lang.Object- Returns:
- a string with name and prefix
-
-