public abstract class Vehicle
extends java.lang.Object
Locomotive and Coach. Vehicles have positions that can be modified,
that is, they can be moved without being pulled and can also pull objects.
A Vehicle can also and arrive at and depart from a Station.| Modifier and Type | Class and Description |
|---|---|
static interface |
Vehicle.Visitor
The
Visitor interface for the visitor pattern. |
| Constructor and Description |
|---|
Vehicle(Slot currentPlace)
Creates a Vehicle occupying the position given by the parameter
currentPlace
pulling the object given by nextCoach. |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
accept(Vehicle.Visitor visitor) |
void |
arrive(Station station)
Makes the passengers get off this
Vehicle at the Station
if certain conditions are met. |
void |
depart(Station station)
Makes the waiting passengers at the
Station get on this Vehicle
if certain conditions are met. |
protected Slot |
getCurrentPlace()
Returns a reference to the
currentPlace attribute, which is the Slot
occupied by this Vehicle. |
Trailable |
getNextCoach()
Returns a reference to the
nextCoach attribute, which is the coach
pulled by this Vehicle. |
protected void |
setCurrentPlace(Slot currentPlace)
Sets the attribute
currentPlace to the Slot given by the parameter
currentPlace. |
void |
setNextCoach(Coach nextCoach)
Sets the
nextCoach attribute of the Coach given by the parameter
nextCoach to the nextCode attribute of this, then sets the nextCoach
attribute of this to the Coach given by the parameter nextCoach,
thus inserting the nextCoach parameter into the chain of train elements
right after this Vehicle. |
void |
setNextCoach(Trailable nextCoach)
Sets the
nextCoach attribute of this to the Coach given by the parameter
nextCoach. |
public Vehicle(Slot currentPlace)
currentPlace
pulling the object given by nextCoach.currentPlace - a Slot to be occupied by the new Vehiclepublic Trailable getNextCoach()
nextCoach attribute, which is the coach
pulled by this Vehicle.Trailable object pulled by this Vehiclepublic void setNextCoach(Coach nextCoach)
nextCoach attribute of the Coach given by the parameter
nextCoach to the nextCode attribute of this, then sets the nextCoach
attribute of this to the Coach given by the parameter nextCoach,
thus inserting the nextCoach parameter into the chain of train elements
right after this Vehicle.nextCoach - a Trailable coach, which will be pulled by this Vehiclepublic void setNextCoach(Trailable nextCoach)
nextCoach attribute of this to the Coach given by the parameter
nextCoach.nextCoach - a Trailable coach, which will be pulled by this Vehicleprotected Slot getCurrentPlace()
currentPlace attribute, which is the Slot
occupied by this Vehicle.Slot that is occupied by this Vehicleprotected void setCurrentPlace(Slot currentPlace)
currentPlace to the Slot given by the parameter
currentPlace.currentPlace - the Slot to move to by this Vehiclepublic void arrive(Station station)
Vehicle at the Station
if certain conditions are met.station - the Station to check for its Colorpublic void depart(Station station)
Station get on this Vehicle
if certain conditions are met.station - the Station to check for its passengers and Colorpublic abstract void accept(Vehicle.Visitor visitor)