井字游戏数组检查游戏结束

huangapple go评论71阅读模式
英文:

Tic Tac Toe Array Check Game over

问题

我无法理解这个作业提示,感觉自己像个白痴。

作业提示如下:
声明并实现一个名为gameOver的函数。gameOver接收一个3x3的char[][]数组作为参数,表示井字棋盘,每个单元格包含X、O或(空格)。如果X赢得比赛,gameOver应返回X;如果O赢得比赛,应返回O;否则返回空格(' ')。不要检查对角线!

有人可以给我一些建议吗?

英文:

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.

答案1

得分: 1

这要求你实现一个函数,该函数接受一个棋盘并返回获胜者或平局。

以下是如何在Java中声明一个函数:

public char gameOver(char[][] board) {
   char winner = ' '; 
   // 你的实现在这里。
   return winner;
}

在函数的实现中,你需要扫描棋盘并找出获胜者,然后将其赋值给winner变量。

在查看注释中编写的解决方案之前,最好先自己尝试一下。

英文:

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.

huangapple
  • 本文由 发表于 2020年9月17日 09:54:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/63930183.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定