Skip to content
Snippets Groups Projects
Commit 4f206429 authored by Timon Harries's avatar Timon Harries
Browse files

fixed checkForWin board function

parent c5fbdf5e
No related branches found
No related tags found
1 merge request!1Verision 1.0 finished
......@@ -49,16 +49,16 @@ public class Board{
public boolean checkForWin(){
//checks rows and columns
for(int i = 0; i < 3; i++) {
if(gameboard[i][0] == gameboard[i][1] && gameboard[i][0] == gameboard[i][2] && gameboard[i][0] != '#') {
if((gameboard[i][0] == gameboard[i][1]) && (gameboard[i][0] == gameboard[i][2]) && (gameboard[i][0] != '#')) {
this.setWinner(gameboard[i][0]);
return true;
}
if(gameboard[0][i] == gameboard[1][i] && gameboard[0][i] == gameboard[2][i] && gameboard[i][0] != '#') {
if((gameboard[0][i] == gameboard[1][i]) && (gameboard[0][i] == gameboard[2][i]) && (gameboard[i][0] != '#')) {
this.setWinner(gameboard[i][0]);
return true;
}
}
}
//checks diagonals
if((gameboard[0][0] == gameboard[1][1] && gameboard[0][0] == gameboard[2][2]) || (gameboard[0][2] == gameboard[1][1] && gameboard[0][2] == gameboard[2][0] && gameboard[1][1] != '#')) {
this.setWinner(gameboard[1][1]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment