0

I can't figure out this homework prompt I feel like an idiot.

This is the prompt: Declare and implement a function called gameOver. gameOver receives a single 3x3 char[][] array as a parameter, representing a tic-tac-toe board, with each cell containing either a X, a O, or a (blank space). gameOver should return X if X has won the game, O if O has won the game, and a blank space (' ') otherwise. Do not check the diagonals!

Can someone give me some advice on this.

  • First, don't be so hard on yourself. Given that this is a homework assignment, you are probably new. Programming takes time to learn just like any other skill. Second, this is not really how this site works. Please provide something you've tried and we can help with it. Generally people will put as much effort into an answer as the person put into asking it. As a hint, you will need nested loops. – Neil Locketz Sep 17 '20 at 02:05

1 Answers1

1

It is asking you to implement a function that takes a board and returns the winner or a draw.

Here is how you declare a function in java:

public char gameOver(char[][] board) {
   char winner = ' '; 
   you implementation goes here.
   return winner;
}

In the function implementation you have to scan the board and figure out who is the winner and assigning it to the winner variable.

Before looking up the solution written in the comment it is best for you if you try it yourself.

Gerardo Zinno
  • 1,518
  • 1
  • 13
  • 35