Package model
Class CrossroadRegion
java.lang.Object
model.CrossroadRegion
- All Implemented Interfaces:
Region
public class CrossroadRegion extends java.lang.Object implements Region
CrossroadRegion is a region type that holds three "next positions" and a method for switching between these to
assign the regions actual next position.
-
Constructor Summary
Constructors Constructor Description CrossroadRegion() -
Method Summary
Modifier and Type Method Description voidaddCrossRegion(Region r)addCrossRegion() - Assigns alternative regions for troops to pass from a crossroad region in an array list.PositiongetNext()getNext()RegiongetNextRegion()getNextRegion()PositiongetPosition()getPosition()voidlandOn(Troop t)voidonClick()onClick() - When invoked changes next region from array with alternative regions.voidsetNextPositions(Position pos1, Position pos2, Position pos3)setNextPositions() - Takes the three surrounding positions and puts them into an array.voidsetNextRegion(Region r)setNextRegion()voidsetPos(Position pos)setPos() - Sets position of this region.voidsetPosition(int row, int col)setPosition()voidsetUp()setUp() - Creates array list for holding regions closest to crossroad region.voidswitchDirection()switchDirection() - Switches between the three next positions found in the objects array of next positions and sets it to the next position.
-
Constructor Details
-
CrossroadRegion
public CrossroadRegion()
-
-
Method Details
-
setPos
setPos() - Sets position of this region.- Parameters:
pos- - Position to be set.
-
switchDirection
public void switchDirection()switchDirection() - Switches between the three next positions found in the objects array of next positions and sets it to the next position. -
setNextPositions
setNextPositions() - Takes the three surrounding positions and puts them into an array.- Parameters:
pos1- - First position to be set.pos2- - Second position to be set.pos3- - Third position to be set.
-
addCrossRegion
addCrossRegion() - Assigns alternative regions for troops to pass from a crossroad region in an array list.- Parameters:
r- - Region to be put into "alternatives" array.
-
setUp
public void setUp()setUp() - Creates array list for holding regions closest to crossroad region. -
onClick
public void onClick()onClick() - When invoked changes next region from array with alternative regions. -
getNext
getNext() -
landOn
-
getNextRegion
getNextRegion()- Specified by:
getNextRegionin interfaceRegion- Returns:
- - Next region (changed by onClick method, taken from array list with alternative regions).
-
setNextRegion
setNextRegion()- Specified by:
setNextRegionin interfaceRegion- Parameters:
r- - Region to be set.
-
setPosition
public void setPosition(int row, int col)setPosition()- Specified by:
setPositionin interfaceRegion- Parameters:
row- - Row to be set as x coordinate in position.col- - Column to be set as y coordinate in position.
-
getPosition
getPosition()- Specified by:
getPositionin interfaceRegion- Returns:
- - Position of crossroad region.
-