public class Controller
extends java.lang.Object
Controller class represents the Controller in the MVC model.
It keeps track of the open Portals, the existing
Locomotives, a single Tunnel, and the length of it,
which the Controller can change.| Constructor and Description |
|---|
Controller()
Constructs a controller with empty content.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLocomotive(Locomotive locomotive)
Adds a locomotive to the game board.
|
void |
addOpenedPortal(Portal portal)
Stores the reference of a newly opened
Portal. |
void |
buildMap1(Field field)
Builds an example map layout to field.
|
void |
buildMap2(Field field)
Builds an example map layout to field.
|
void |
finishTrain(Locomotive locomotive)
Removes a train identified by its
Locomotive. |
void |
removeOpenedPortal(Portal portal)
Removes a portal which is already opened.
|
void |
setTunnelLength(int length)
Sets
length as the value to the attribute tunnelLength, which
determines the length of the Tunnels, that is, the number of rails in Tunnels
to be opened. |
boolean |
step()
Performs a game step.
|
void |
unFinishTrain(Locomotive locomotive)
Removes locomotive from the set of finished trains, in case of it was reported as finished by mistake.
|
public Controller()
public void addOpenedPortal(Portal portal)
Portal. If there's another one
already open, it also creates a Tunnel between the two.portal - the Portal to be kept track ofpublic void setTunnelLength(int length)
length as the value to the attribute tunnelLength, which
determines the length of the Tunnels, that is, the number of rails in Tunnels
to be opened.length - the length to be set as the length of future Tunnelspublic void finishTrain(Locomotive locomotive)
Locomotive. If there are no trains left
after the removal, it tells the Player that they won.locomotive - the Locomotive to be removedpublic void unFinishTrain(Locomotive locomotive)
locomotive - the locomotive to unfinishpublic boolean step()
public void removeOpenedPortal(Portal portal)
portal - the item to remove.public void addLocomotive(Locomotive locomotive)
locomotive - the item to add.public void buildMap1(Field field)
field - the map will be placed on field.public void buildMap2(Field field)
field - the map will be placed on field.