public final class Garage
extends java.lang.Object
Garage.getInstance
to get his unique instance.
It is really important to remember that vehicle's name must be unique.Modifier and Type | Method and Description |
---|---|
IModelVehicle |
createVehicle(java.lang.String vehicle,
java.lang.String name)
Create a new vehicle giving vehicle's common name as first parameter
and vehicle's unique name as second.
|
void |
deleteVehicle(java.lang.String name)
Delete a vehicle giving its unique name.
|
java.util.List<java.lang.String> |
getAllVehiclesTypes()
Return name of all vehicles available at instantiation.
|
static Garage |
getInstance()
Return the unique instance of Garage.
|
IModelVehicle |
getVehicle(Coordinates positionToSearch)
Given a position, it returns a vehicle if standing in that
position, null otherwise.
|
IModelVehicle |
getVehicle(java.lang.String name)
Returns only a vehicle giving its unique name.
|
IModelVehicle[] |
getVehicles()
Return a set with all vehicles stored in Garage.
|
void |
startAllVehicles()
This method start all vehicles' thread, if they aren't already running.
|
void |
startVehicle(java.lang.String name)
This method start a vehicle's thread, if it isn't already running.
|
void |
stopAllVehicles()
Stop/pause all vehicle's threads running.
|
void |
stopVehicle(java.lang.String name)
This method stop a running vehicle's thread, if it is.
|
public static Garage getInstance()
public IModelVehicle createVehicle(java.lang.String vehicle, java.lang.String name)
vehicle
- type-name of the vehicle.
Example: "ModelCar", where 'car' is the common namename
- unique name given to that new vehicle.public void deleteVehicle(java.lang.String name)
name
- unique name of the vehicle to be deletedpublic IModelVehicle[] getVehicles()
public IModelVehicle getVehicle(java.lang.String name)
name
- unique name of the vehiclepublic IModelVehicle getVehicle(Coordinates positionToSearch)
positionToSearch
- position's coordinates in
which method will searchpublic void startVehicle(java.lang.String name)
name
- unique name of vehicle's modelpublic void startAllVehicles()
public void stopVehicle(java.lang.String name)
name
- unique name of vehicle's modelpublic void stopAllVehicles()
public java.util.List<java.lang.String> getAllVehiclesTypes()