Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
<groupId>rocks.zipcodewilmington</groupId>
<artifactId>tic-tac-toe</artifactId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
Expand Down
92 changes: 85 additions & 7 deletions src/main/java/rocks/zipcodewilmington/tictactoe/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,101 @@
* @author leon on 6/22/18.
*/
public class Board {
private Character [][] matrix; // Intitialized it

public Board(Character[][] matrix) {
this.matrix = matrix; // addded the thi.matrix....


}


public Boolean isInFavorOfX() {
return null;
}

int theX = 0;
int theO = 0;
Character[][] board = this.matrix;
if (isTie()){
return false;
}

for (int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){

if (board [i][j] == 'X') {
theX++;
}else if (board [i][j] == 'O'){
theO++;
}
}
}

return theX > theO;




} // favor of X







public Boolean isInFavorOfO() {
return null;
return !isTie() && isInFavorOfX() == false;
}

public Boolean isTie() {
return null;

return getWinner() == "";
}










public String getWinner() {
return null;
}
Character [][] board = this.matrix;

if (board[0][0] == 'X' && board[1][1] == 'X' && board[2][2] == 'X'){
return "X";
}else if (board[2][0] == 'X' && board[1][1] == 'X' && board[0][2] == 'X'){
return "X";
}else if (board[0][0] == 'O' && board[1][1] == 'O' && board[2][2] == 'O'){
return "O";
}else if (board[2][0] == 'O' && board[1][1] == 'O' && board[0][2] == 'O'){
return "O";
}

for (int i = 0; i < 3; i++){ // horizontal

if (board [i][0] == 'X' && board[i][1] == 'X' && board[i][2] == 'X'){
return "X";
}else if (board [i][0] == 'O' && board[i][1] == 'O' && board[i][2] == 'O'){
return "O";
}


} // for loop

for(int i = 0; i < 3; i++){ // vertical

if (board [0][i] == 'X' && board[1][i] == 'X' && board[2][i] == 'X'){
return "X";
}else if (board [0][1] == 'O' && board[1][i] == 'O' && board[2][i] == 'O'){
return "O";
}

} //2nd for loop

return "";
} // get winner

}
} // the last