Constructor and Description |
---|
Slot() |
Modifier and Type | Method and Description |
---|---|
void |
acquire(Vehicle thisVehicle)
Sets the
Slot to be occupied by the Vehicle given by thisVehicle
by adding it to the set attribute content , which contains all vehicles occupying
this Slot . |
void |
addStation(Station station)
Adds a
Station to the list of stations, which are next to the Slot . |
void |
arrive(Vehicle vehicle)
Tries to make the passengers get off the
Vehicle given by the parameter vehicle
at the Station s next to this Slot . |
boolean |
checkCollision()
Returns if there are more than one occupants on this
Slot . |
void |
depart(Vehicle vehicle)
Tries to make the waiting passengers at the
Station s next to this Slot get on
the Vehicle given by the parameter vehicle . |
abstract Slot |
getNextSlot(Slot previousSlot)
Returns the
Slot an object must move to after its next step determined by
previousSlot . |
Station |
getStation()
Returns "the" station which stands next to this slot, null there are no stations next to it.
|
Vehicle |
getVehicle()
Returns "the" vehicle which stands on this slot, null if empty.
|
protected boolean |
isAcquired()
Returns if this
Slot has any occupants. |
void |
release(Vehicle thisVehicle)
Removes the
Vehicle given by thisVehicle from the set attribute
content thus making it no longer occupy this Slot . |
public abstract Slot getNextSlot(Slot previousSlot)
Slot
an object must move to after its next step determined by
previousSlot
.previousSlot
- Slot
that determines the direction of movementSlot
to move topublic void addStation(Station station)
Station
to the list of stations, which are next to the Slot
.station
- the Station
to be addedpublic void arrive(Vehicle vehicle)
Vehicle
given by the parameter vehicle
at the Station
s next to this Slot
.vehicle
- the vehicle which arrived.public void depart(Vehicle vehicle)
Station
s next to this Slot
get on
the Vehicle
given by the parameter vehicle
.vehicle
- the vehicle which departed.public void acquire(Vehicle thisVehicle)
Slot
to be occupied by the Vehicle
given by thisVehicle
by adding it to the set attribute content
, which contains all vehicles occupying
this Slot
.thisVehicle
- Vehicle
to be added to the set content
representing the
occupants of this Slot
public void release(Vehicle thisVehicle)
Vehicle
given by thisVehicle
from the set attribute
content
thus making it no longer occupy this Slot
.thisVehicle
- Vehicle
to removed from the set content
representing the
occupants of this Slot
protected boolean isAcquired()
Slot
has any occupants. Checks for this information by
inspecting the set attribute content
's size.true
if the set attribute content
has any occupants,
false
if it doesn'tpublic boolean checkCollision()
Slot
. Checks for this information by
inspecting the set attribute content
's size.true
if the set attribute content
has at least 2 occupants,
false
if it doesn'tpublic Vehicle getVehicle()
public Station getStation()