Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Compete the function checkBoard that we began in lecture earlier this week for checking a 3-by-3 Tic-Tac-Toe board. If needed, you can review the rules

Compete the function checkBoard that we began in lecture earlier this week for checking a 3-by-3 Tic-Tac-Toe board. If needed, you can review the rules of Tic-tac-toe here.

Your function will receive a 3-by-3 two-dimensional array of characters, with each space containing an X, O, or a . if nobody has played in that position. You should return the char X if X has won the game, O if O has won the game, and . if neither player has won. Note that you should only check for vertical and horizontal winners, not diagonals. (Checking for diagonals will actually cause your submission to fail our tests.)

The passed board may be null. In that case you should return that neither player has won.

Starting Code:

char[][] currentBoard = {{'X', 'O', '.'}, {'O', 'X', '.'}, {'O', '.', 'X'}};

// Return the winner if the game is over, '.' otherwise static char checkBoard(char[][] board) {

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Office 365 For Beginners 2022 8 In 1

Authors: James Holler

1st Edition

B0B2WRC1RX, 979-8833565759

More Books

Students also viewed these Databases questions