Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4. 120 pointsl Write a method, flipHorizontal, that would help implement the gam

ID: 3569589 • Letter: 4

Question

4. 120 pointsl Write a method, flipHorizontal, that would help implement the game of reversi. Your method checks to see if the given symbol now surrounds a sequence ofopponent pieces in the horizontal direction and if so, flips them by assigning the given symbol to those places on the board. For ease of understanding, here is the board as it should appear in the tests after each of the 3 calls to your method with row/column t's labeled: test board after CALL #1 after CALL #2 after CALL #3 0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5 0 0 0 X 0 0 0 X 0 0 X 0 0 0 X X X X X 2 0 2 0 2 0 2 X X X X X 3 0 0 0 3 0 0 0 X X 0 X X 0 X X O X X 0 public void test flipHorizontal char[][] board copy (test board) board [1][4] 'X' flipHorizontal (board, 1, 4, 'X', 0'); CALL #1 assertEquals X board [1][3]) assert Equals X board [1][2]) board [3][0] flipHorizontal (board, 3, 0, '0', 'X'); CALL #2 assert Equals board [3][1]) board [2][2] 'X' flipHorizontal (board, 2, 2, 'X', 0'); CALL #3 assert board [2][1]) assert Equals X board [2][3]) Your code must work for the game in general and pass the test. You will probably want to write some helper functions. public static void flipHorizontal (char[][] board, int row, int col, char symbol, char oppositeSymbol)

Explanation / Answer

contact on timacs12@gmail.com

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote