diff --git a/src/main/java/Game/Tictactoe.java b/src/main/java/Game/Tictactoe.java index 5be7517..0988a12 100644 --- a/src/main/java/Game/Tictactoe.java +++ b/src/main/java/Game/Tictactoe.java @@ -3,6 +3,8 @@ package Game; import java.util.ArrayList; public class Tictactoe implements Game { + + enum State { CIRCLE, CROSS, @@ -10,6 +12,15 @@ public class Tictactoe implements Game { } private ArrayList outputBuffer = new ArrayList(); private String input; + private State[] currentBoard; + + public Tictactoe() { + init(); + } + + private void init() { + currentBoard = newBoard(); + } @Override public void print() { @@ -31,8 +42,19 @@ public class Tictactoe implements Game { } } + private State[] newBoard() { + State[] board = new State[9]; + for (int i = 0; i < board.length; i++) { + board[i] = State.EMPTY; + } + return board; + } void setOutputBuffer(ArrayList outputBuffer){ this.outputBuffer = outputBuffer; } + + public State[] getCurrentBoard() { + return currentBoard; + } } diff --git a/src/test/java/Game/TictactoeTest.java b/src/test/java/Game/TictactoeTest.java index 39a6f3e..998accf 100644 --- a/src/test/java/Game/TictactoeTest.java +++ b/src/test/java/Game/TictactoeTest.java @@ -47,4 +47,12 @@ class TictactoeTest { assertEquals(ttt.getStatedChar(Tictactoe.State.CROSS), 'X'); assertEquals(ttt.getStatedChar(Tictactoe.State.EMPTY), ' '); } + + @Test + void testForEmptyBoardOnInitialization() { + Tictactoe.State[] board = ttt.getCurrentBoard(); + for (int i = 0; i < board.length; i++) { + assertEquals(board[i], Tictactoe.State.EMPTY); + } + } } \ No newline at end of file