|
@ -3,6 +3,8 @@ package Game; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
public class Tictactoe implements Game { |
|
|
public class Tictactoe implements Game { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum State { |
|
|
enum State { |
|
|
CIRCLE, |
|
|
CIRCLE, |
|
|
CROSS, |
|
|
CROSS, |
|
@ -10,6 +12,15 @@ public class Tictactoe implements Game { |
|
|
} |
|
|
} |
|
|
private ArrayList<String> outputBuffer = new ArrayList<String>(); |
|
|
private ArrayList<String> outputBuffer = new ArrayList<String>(); |
|
|
private String input; |
|
|
private String input; |
|
|
|
|
|
private State[] currentBoard; |
|
|
|
|
|
|
|
|
|
|
|
public Tictactoe() { |
|
|
|
|
|
init(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void init() { |
|
|
|
|
|
currentBoard = newBoard(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void print() { |
|
|
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<String> outputBuffer){ |
|
|
void setOutputBuffer(ArrayList<String> outputBuffer){ |
|
|
this.outputBuffer = outputBuffer; |
|
|
this.outputBuffer = outputBuffer; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public State[] getCurrentBoard() { |
|
|
|
|
|
return currentBoard; |
|
|
|
|
|
} |
|
|
} |
|
|
} |