Package cpsc2150.extendedConnectX.models

# Class GameBoard

java.lang.Object
cpsc2150.extendedConnectX.models.AbsGameBoard
cpsc2150.extendedConnectX.models.GameBoard

All Implemented Interfaces:
  `IGameBoard`

public class GameBoard extends AbsGameBoard implements IGameBoard
Class that represents an entire game board for the ExtendedConnectX game using an array.

This class includes methods to place tokens, check token locations, and determine whether or not the game has been won or is over.

Invariant:
  (board[][] = ' ' OR board[][] = [ a player token ]) AND [ there are no gaps between non-space tokens ] AND MIN_ROWS `<=` numRows `<` MAX_ROWS AND MIN_COLUMNS `<=` numColumns `<` MAX_COLUMNS MIN_NUM_TO_WIN `<=` numToWin `<=` MAX_NUM_TO_WIN

- ## Field Summary

  ### Fields inherited from interface cpsc2150.extendedConnectX.models.IGameBoard

  `MAX_COLUMNS, MAX_NUM_TO_WIN, MAX_ROWS, MIN_COLUMNS, MIN_NUM_TO_WIN, MIN_ROWS`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GameBoard(int rows, int columns, int win)`
  Constructor for GameBoard that takes parameters for the number of rows, the number of columns, and the number needed to win, and initializes all indexes of board to ' '.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getNumColumns()`
  Returns the number of columns in the GameBoard.
  `int`
  `getNumRows()`
  Returns the number of rows in the GameBoard.
  `int`
  `getNumToWin()`
  Returns the number of tokens in a row needed to win the game.
  `void`
  `placeToken(char p, int c)`
  Function that places the character p in column c.
  `char`
  `whatsAtPos(BoardPosition pos)`
  Function that returns what is in the GameBoard at position pos.

  ### Methods inherited from class cpsc2150.extendedConnectX.models.AbsGameBoard

  `toString`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface cpsc2150.extendedConnectX.models.IGameBoard

  `checkDiagWin, checkForWin, checkHorizWin, checkIfFree, checkTie, checkVertWin, isPlayerAtPos`

- ## Constructor Details

  - ### GameBoard

    public GameBoard(int rows, int columns, int win)
    Constructor for GameBoard that takes parameters for the number of rows, the number of columns, and the number needed to win, and initializes all indexes of board to ' '.
    Parameters:
      `rows` - Number of rows
      `columns` - Number of columns
      `win` - Number needed to win
    Pre:
      MIN_ROWS `<=` rows `<` MAX_ROWS AND MIN_COLUMNS `<=` columns `<` MAX_COLUMNS AND MIN_NUM_TO_WIN `<=` win `<=` MAX_NUM_TO_WIN AND win `<=` rows AND win `<=` columns
    Post:
      board[][] = ' ' AND numRows = rows AND numColumns = columns AND numToWin = win AND [ size of board[] ] = numRows AND [ size of board[][] ] = numColumns

- ## Method Details

  - ### placeToken

    public void placeToken(char p, int c)
    Description copied from interface: `IGameBoard`
    Function that places the character p in column c. The token will be placed in the lowest available row in column c.
    Specified by:
      `placeToken` in interface `IGameBoard`
    Parameters:
      `p` - Character to be placed (representing player token)
      `c` - Column to place token in

  - ### whatsAtPos

    public char whatsAtPos(BoardPosition pos)
    Description copied from interface: `IGameBoard`
    Function that returns what is in the GameBoard at position pos. If no marker is there, it returns a blank space char.
    Specified by:
      `whatsAtPos` in interface `IGameBoard`
    Parameters:
      `pos` - BoardPosition pair of row and column
    Returns:
      Character representing player token or space

  - ### getNumRows

    public int getNumRows()
    Description copied from interface: `IGameBoard`
    Returns the number of rows in the GameBoard.
    Specified by:
      `getNumRows` in interface `IGameBoard`
    Returns:
      The number of rows

  - ### getNumColumns

    public int getNumColumns()
    Description copied from interface: `IGameBoard`
    Returns the number of columns in the GameBoard.
    Specified by:
      `getNumColumns` in interface `IGameBoard`
    Returns:
      The number of columns

  - ### getNumToWin

    public int getNumToWin()
    Description copied from interface: `IGameBoard`
    Returns the number of tokens in a row needed to win the game.
    Specified by:
      `getNumToWin` in interface `IGameBoard`
    Returns:
      The number of tokens