Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finished and tested tic tac toe #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 61 additions & 4 deletions src/main/java/rocks/zipcodewilmington/tictactoe/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,81 @@
/**
* @author leon on 6/22/18.
*/


public class Board {

Character[][] playerChoice;
public Board(Character[][] matrix) {
playerChoice = matrix;

}

public Boolean isInFavorOfX() {
return null;
if (playerChoice[0][0]== 'X' && playerChoice[0][1] == 'X' && playerChoice[0][2] == 'X'){
return true;
} else if (playerChoice[1][0] == 'X' && playerChoice[1][1] == 'X' && playerChoice[1][2] == 'X') {
return true;
} else if (playerChoice[2][0] == 'X' && playerChoice[2][1] == 'X' && playerChoice[2][2] == 'X') {
return true;
} else if (playerChoice[0][0] == 'X' && playerChoice[1][0] == 'X' && playerChoice[2][0] == 'X') {
return true;
} else if (playerChoice[0][1] == 'X' && playerChoice[1][1] == 'X' && playerChoice[2][1] == 'X') {
return true;
} else if (playerChoice[0][2] == 'X' && playerChoice[1][2] == 'X' && playerChoice[2][2] == 'X') {
return true;
} else if (playerChoice[0][0] == 'X' && playerChoice[1][1] == 'X' && playerChoice[2][2] == 'X') {
return true;
} else if (playerChoice[0][2] == 'X' && playerChoice[1][1] == 'X' && playerChoice[2][0] == 'X'){
return true;
} else {
return false;
}



}

public Boolean isInFavorOfO() {
return null;
if (playerChoice[0][0] == 'O' && playerChoice[0][1] == 'O' && playerChoice[0][2] == 'O') {
return true;
} else if (playerChoice[1][0] == 'O' && playerChoice[1][1] == 'O' && playerChoice[1][2] == 'O') {
return true;
} else if (playerChoice[2][0] == 'O' && playerChoice[2][1] == 'O' && playerChoice[2][2] == 'O') {
return true;
} else if (playerChoice[0][0] == 'O' && playerChoice[1][0] == 'O' && playerChoice[2][0] == 'O') {
return true;
} else if (playerChoice[0][1] == 'O' && playerChoice[1][1] == 'O' && playerChoice[2][1] == 'O') {
return true;
} else if (playerChoice[0][2] == 'O' && playerChoice[1][2] == 'O' && playerChoice[2][2] == 'O') {
return true;
} else if (playerChoice[0][0] == 'O' && playerChoice[1][1] == 'O' && playerChoice[2][2] == 'O') {
return true;
} else if (playerChoice[0][2] == 'O' && playerChoice[1][1] == 'O' && playerChoice[2][0] == 'O'){
return true;
} else {
return false;
}


}

public Boolean isTie() {
return null;
if (isInFavorOfO() == isInFavorOfX()) {
return true;
} else {
return false;
}
}

public String getWinner() {
return null;
if (this.isInFavorOfO()) {
return "O";
} else if (this.isInFavorOfX()) {
return "X";
}else {
return "";
}
}

}