Class BoardPosition

java.lang.Object
cpsc2150.extendedConnectX.models.BoardPosition

public class BoardPosition extends Object
Keep track of an individual cell for a board.

This class keeps row and column information for a single cell on the game board and provides methods to get the row and column numbers.

Invariant:
0 >= row < IGameBoard.MAX_ROWS AND 0 >= column < IGameBoard.MAX_COLUMNS
  • Constructor Summary

    Constructors
    Constructor
    Description
    BoardPosition(int Row, int Column)
    Constructor for BoardPosition that takes integers for row and column.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Overloaded equals method for BoardPosition.
    int
    This function returns the value of the column number.
    int
    This function returns the value of the row number.
    Overloaded toString method for BoardPosition.

    Methods inherited from class java.lang.Object

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

    • BoardPosition

      public BoardPosition(int Row, int Column)
      Constructor for BoardPosition that takes integers for row and column.
      Parameters:
      Row - number corresponding to row
      Column - number corresponding to column
      Pre:
      0 >= Row < IGameBoard.MAX_ROWS AND 0 >= IGameBoard.Column < MAX_COLUMNS
      Post:
      row = Row AND column = Column
  • Method Details

    • equals

      public boolean equals(Object o)
      Overloaded equals method for BoardPosition.
      Overrides:
      equals in class Object
      Parameters:
      o - Object to check if equal to
      Returns:
      Whether two BoardPosition objects are equal
      Post:
      equals = true iff ((BoardPosition) o = this) AND row = #row AND column = #column equals = false iff ((BoardPosition) o != this) AND row = #row AND column = #column
    • toString

      public String toString()
      Overloaded toString method for BoardPosition.

      NOTE: The string will change depending on the values of the BoardPosition object that calls the toString method, and thus the post-condition for this method is partially informal.

      Overrides:
      toString in class Object
      Returns:
      A string in the format ","
      Post:
      [toString is formatted like ","] AND row = #row AND column = #column
    • getRow

      public int getRow()
      This function returns the value of the row number.
      Returns:
      The row value
      Post:
      getRow = row AND row = #row AND column = #column
    • getColumn

      public int getColumn()
      This function returns the value of the column number.
      Returns:
      The column value
      Post:
      getColumn = column AND row = #row AND column = #column