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 void
addCrossRegion(Region r)
addCrossRegion() - Assigns alternative regions for troops to pass from a crossroad region in an array list.Position
getNext()
getNext()Region
getNextRegion()
getNextRegion()Position
getPosition()
getPosition()void
landOn(Troop t)
void
onClick()
onClick() - When invoked changes next region from array with alternative regions.void
setNextPositions(Position pos1, Position pos2, Position pos3)
setNextPositions() - Takes the three surrounding positions and puts them into an array.void
setNextRegion(Region r)
setNextRegion()void
setPos(Position pos)
setPos() - Sets position of this region.void
setPosition(int row, int col)
setPosition()void
setUp()
setUp() - Creates array list for holding regions closest to crossroad region.void
switchDirection()
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:
getNextRegion
in interfaceRegion
- Returns:
- - Next region (changed by onClick method, taken from array list with alternative regions).
-
setNextRegion
setNextRegion()- Specified by:
setNextRegion
in interfaceRegion
- Parameters:
r
- - Region to be set.
-
setPosition
public void setPosition(int row, int col)setPosition()- Specified by:
setPosition
in 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:
getPosition
in interfaceRegion
- Returns:
- - Position of crossroad region.
-