Implement a representation of the connect four board in a class called Board Boa
ID: 3571383 • Letter: I
Question
Implement a representation of the connect four board in a class called Board Board representation details: You are free to implement any additional methods if you wish and include any data structures/variables you feel would be necessary. However, you MUST implement ALL of the methods described in Task2 for full credit. (0, 0) represents the upper left corner of the board, (i.e. if a player were to place a token in column 0, the first token to be placed would fall to(r-l, 0) where r is the number of rows in your board. All positions in the board should be initialized to an empty space'' Task1: Define your fields (aka instance variables) necessary to implement the following operations Task2: implement the following methods: Your Board.java MUST have the following methods (DO NOT MODIFY ANY OF THE METHOD SIGNATURES) Constructors: Board();//creates a default board of size 7 columns x 6 rows Board(int row, int col);//creates a board of size row x col Both constructors above should initialize all positions to'' public int getNumRows();//returns the number of rows in board public int getNumCols();//returns the number of cols in board public char getPlayerOne();//returns char representing player 1 public char getPlayerTwo();//returns char representing player 2 public void setPlayerOne(char o);//sets char representing player 1 public void setPlayerTwo(char t);//sets char representing player 2 public char getToken(int row, int col);//returns the char representing token at location row, col, returns '' if indices are invalid public boolean can Play();//returns true if a token is still able to placed onto the board, false otherwise public boolean play(int p, int c);//places the appropriate token for player pin column c. returns true if successful, false otherwise. public int isFinished();//returns either the ID of the player who has won (1 or 2) OR 0 if the game has ended in a tie OR -1 if nobody has won yetExplanation / Answer
public class Board { private char arr[][]; private char playerOne; private char playerTwo; private int numRows; private int numCols; public Board() { this.arr = new char[6][7]; for(int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.