Problem

Playing CompilerFind and correct the syntax and logic error(s) in the following class. Boa...

Playing Compiler

Find and correct the syntax and logic error(s) in the following class. Board encapsulates a two-person game. Board uses a two-dimensional array that holds pieces of type . Board also remembers whether it is player 1’s turn or player 2’s turn.

      class Board

      {

         private ArrayList items;

         int turn;      // which player's turn, 1 or 2

         public Board()

         // default constructor

         {

            items =.new bo[8][8];

            turn = 1;

         } // creates an empty 8 by 8 two-dimensional array

         public Board(int initialCapacity, int player )

               // one-argument constructor, creates 2-dim array

               // with initialCapacityrows and columns

         {

            items = new bo[initialCapacity] [initialCapacity];

            turn = player;

         }

         public Board(int initialRowCapacity, int initialColumnCapacity, int player)

                 // two-argument constructor, creates 2-dim array with

                 // initialCapacityrows and columns

         {

            items = new bo[initialCapacity] [initialCapacity];

            turn = player;

         }

         public T whoseturn()

         // accessor for whose turn it is

         {

            return (turn);

         }

         public T addtoBoard(T item, int row, int col)

         // lets you put a piece on the board

         {

           bo[row, col] = item;

         }

         public T peek(int row, int col)

         // lets you peek at a piece on the board

         {

           return bo[row][col];

         }

         public void switchturn()

         // lets you switch whose turn it is

         {

           if (turn == 1)

                  turn = 2;

           if (turn == 2)

                  turn = 1;

         }

      }

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 16
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT