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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • setPos

      public void setPos​(Position pos)
      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

      public void setNextPositions​(Position pos1, Position pos2, Position pos3)
      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

      public void addCrossRegion​(Region r)
      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.
      Specified by:
      setUp in interface Region
    • onClick

      public void onClick()
      onClick() - When invoked changes next region from array with alternative regions.
      Specified by:
      onClick in interface Region
    • getNext

      public Position getNext()
      getNext()
      Specified by:
      getNext in interface Region
      Returns:
      - Position of next region (changed by onClick method).
    • landOn

      public void landOn​(Troop t)
      Specified by:
      landOn in interface Region
    • getNextRegion

      public Region getNextRegion()
      getNextRegion()
      Specified by:
      getNextRegion in interface Region
      Returns:
      - Next region (changed by onClick method, taken from array list with alternative regions).
    • setNextRegion

      public void setNextRegion​(Region r)
      setNextRegion()
      Specified by:
      setNextRegion in interface Region
      Parameters:
      r - - Region to be set.
    • setPosition

      public void setPosition​(int row, int col)
      setPosition()
      Specified by:
      setPosition in interface Region
      Parameters:
      row - - Row to be set as x coordinate in position.
      col - - Column to be set as y coordinate in position.
    • getPosition

      public Position getPosition()
      getPosition()
      Specified by:
      getPosition in interface Region
      Returns:
      - Position of crossroad region.