Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Board functionality #16

Open
4 tasks
ColinLefter opened this issue Mar 12, 2024 · 0 comments
Open
4 tasks

Board functionality #16

ColinLefter opened this issue Mar 12, 2024 · 0 comments
Assignees

Comments

@ColinLefter
Copy link
Owner

ColinLefter commented Mar 12, 2024

  • Class variables
  • performMove
  • checkStatus
  • getEmptyPositions
public class Board {
    int[][] boardValues;
    public static final int DEFAULT_BOARD_SIZE = 3;
    public static final int IN_PROGRESS = -1;
    public static final int DRAW = 0;
    public static final int P1 = 1;
    public static final int P2 = 2;
    
    // getters and setters
    public void performMove(int player, Position p) {
        this.totalMoves++;
        boardValues[p.getX()][p.getY()] = player;
    }

    public int checkStatus() {
        /* Evaluate whether the game is won and return winner.
           If it is draw return 0 else return -1 */         
    }

    public List<Position> getEmptyPositions() {
        int size = this.boardValues.length;
        List<Position> emptyPositions = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < size; j++) {
                if (boardValues[i][j] == 0)
                    emptyPositions.add(new Position(i, j));
            }
        }
        return emptyPositions;
    }
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants