Package com.uca.flights
Class TripBuilder
- java.lang.Object
-
- com.uca.flights.TripBuilder
-
- All Implemented Interfaces:
java.lang.Cloneable
public class TripBuilder extends java.lang.Object implements java.lang.CloneableTool to build a trip
-
-
Constructor Summary
Constructors Constructor Description TripBuilder()ConstructorTripBuilder(Airport a, java.time.Duration d)ConstructorTripBuilder(Jump j)ConstructorTripBuilder(Step s)ConstructorTripBuilder(Trip trip)ConstructorTripBuilder(TripBuilder tb)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(Airport a, java.time.Duration d)Add a step to the trip buildervoidappend(Jump j)Add a jump to the trip buildervoidappend(Step s)Add a step to the trip buildervoidappend(Trip t)Add a trip to the trip buildervoidappend(TripBuilder tb)Concatenate the two tripbildervoidclear()Clear the tripjava.lang.Objectclone()Redefinition of clonevoidprepend(Airport a, java.time.Duration d)Add a step to the trip buildervoidprepend(Jump j)Add a jump to the trip buildervoidprepend(Step s)Add a step to the trip buildervoidprepend(Trip t)Add a trip to the trip buildervoidprepend(TripBuilder tb)Concatenate the two tripbildervoidremoveFirst()Remove the first step of the tripvoidremoveLast()Remove the last step of the tripvoidsetAbsoluteDuration(boolean b)SetterTriptoRegularTrip()Create a regular tripTriptoTrip()Create a tripvoidupdateDuration()Pass all duration from absolute to relativebooleanuseAbsoluteDuration()Getter
-
-
-
Constructor Detail
-
TripBuilder
public TripBuilder()
Constructor
-
TripBuilder
public TripBuilder(TripBuilder tb)
Constructor- Parameters:
tb- a tribbuilder- Throws:
java.lang.IllegalArgumentException- on null parameter
-
TripBuilder
public TripBuilder(Trip trip)
Constructor- Parameters:
trip- a trip- Throws:
java.lang.IllegalArgumentException- on null parameter
-
TripBuilder
public TripBuilder(Jump j)
Constructor- Parameters:
j- a jump- Throws:
java.lang.IllegalArgumentException- on null parameter
-
TripBuilder
public TripBuilder(Step s)
Constructor- Parameters:
s- a step- Throws:
java.lang.IllegalArgumentException- on null parameter
-
TripBuilder
public TripBuilder(Airport a, java.time.Duration d)
Constructor- Parameters:
a- an airportd- a duration- Throws:
java.lang.IllegalArgumentException- on null parameter
-
-
Method Detail
-
append
public void append(TripBuilder tb)
Concatenate the two tripbilder- Parameters:
tb- a tribbuilder- Throws:
java.lang.IllegalArgumentException- on null or empty parameter
-
prepend
public void prepend(TripBuilder tb)
Concatenate the two tripbilder- Parameters:
tb- a tribbuilder- Throws:
java.lang.IllegalArgumentException- on null or empty parameter
-
append
public void append(Trip t)
Add a trip to the trip builder- Parameters:
t- a trip- Throws:
java.lang.IllegalArgumentException- on null parameter
-
prepend
public void prepend(Trip t)
Add a trip to the trip builder- Parameters:
t- a trip- Throws:
java.lang.IllegalArgumentException- on null parameter
-
append
public void append(Jump j)
Add a jump to the trip builder- Parameters:
j- a jump- Throws:
java.lang.IllegalArgumentException- on null parameter
-
prepend
public void prepend(Jump j)
Add a jump to the trip builder- Parameters:
j- a jump- Throws:
java.lang.IllegalArgumentException- on null parameter
-
append
public void append(Step s)
Add a step to the trip builder- Parameters:
s- a step- Throws:
java.lang.IllegalArgumentException- on null parameter
-
prepend
public void prepend(Step s)
Add a step to the trip builder- Parameters:
s- a step- Throws:
java.lang.IllegalArgumentException- on null parameter
-
append
public void append(Airport a, java.time.Duration d)
Add a step to the trip builder- Parameters:
a- an airportd- a duration- Throws:
java.lang.IllegalArgumentException- on null parameter
-
prepend
public void prepend(Airport a, java.time.Duration d)
Add a step to the trip builder- Parameters:
a- an airportd- a duration- Throws:
java.lang.IllegalArgumentException- on null parameter
-
removeLast
public void removeLast()
Remove the last step of the trip- Throws:
java.lang.IllegalArgumentException- if empty
-
removeFirst
public void removeFirst()
Remove the first step of the trip- Throws:
java.lang.IllegalArgumentException- if empty
-
clear
public void clear()
Clear the trip
-
updateDuration
public void updateDuration()
Pass all duration from absolute to relative- Throws:
java.lang.IllegalArgumentException- if empty
-
toTrip
public Trip toTrip()
Create a trip- Returns:
- a new trip
- Throws:
java.lang.IllegalArgumentException- if empty
-
toRegularTrip
public Trip toRegularTrip()
Create a regular trip- Returns:
- a new regular trip
- Throws:
java.lang.IllegalArgumentException- if empty
-
clone
public java.lang.Object clone()
Redefinition of clone- Overrides:
clonein classjava.lang.Object- Returns:
- a deep copy of this
-
useAbsoluteDuration
public boolean useAbsoluteDuration()
Getter- Returns:
- if absolute duration are used
-
setAbsoluteDuration
public void setAbsoluteDuration(boolean b)
Setter- Parameters:
b- a boolean
-
-