This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class CLIGame extends Game { | |
| ... | |
| public static void main(String[] args) throws IOException { | |
| CLIGame newGame = new CLIGame(); | |
| newGame.startGame(); | |
| newGame.playGame(); | |
| } | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package tictactoe; | |
| import static tictactoe.TictactoeConstants.*; | |
| public class GameSettings { | |
| private UI ui; | |
| private int boardSize; | |
| private Player playerOne; | |
| private Player playerTwo; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package tictactoe; | |
| public class MockGameSettings extends GameSettings { | |
| private UI ui; | |
| private int boardSize; | |
| private Player playerOne; | |
| private Player playerTwo; | |
| private Player playerFirstMove; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Original functions | |
| public void returnBoardSize() { | |
| ui.requestBoardSize(); | |
| String size = ui.returnBoardSize(); | |
| if (tryParse(size)) { | |
| validateBoardSize(size); | |
| Integer intSize = Integer.parseInt(size); | |
| setBoardSize(intSize); | |
| } else { | |
| ui.invalidBoardSizeMessage(size); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public boolean validMove(String move) { | |
| if (tryParse(move)) { // Checks if string can be parsed | |
| int cellIndex = (new Integer(move) - 1); | |
| int totalCellsCount = rows * rows; | |
| return (cellIndex >= 0) && (cellIndex < totalCellsCount) && isOpen(cellIndex); // Checks if parsed value is valid based on game board | |
| } else { | |
| return false; | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public String getNextMove() { | |
| String move = "0"; | |
| while (!board.validMove(move)) { | |
| try { | |
| move = bufferedReader.readLine(); | |
| } catch (IOException e) { | |
| e.printStackTrace(); | |
| } catch (NumberFormatException e) { | |
| e.printStackTrace(); | |
| } finally { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package tictactoe; | |
| import java.io.IOException; | |
| import static tictactoe.TictactoeConstants.O_MARKER; | |
| import static tictactoe.TictactoeConstants.X_MARKER; | |
| /** | |
| * Created by Taryn on 1/18/14. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Main-Class: tictactoe.GameRunner |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package tictactoe; | |
| abstract class AbstractPlayer implements Player { | |
| private String marker; | |
| private Player opponent; | |
| public String getMarker() { | |
| return marker; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package tictactoe; | |
| abstract class AlphaBetaPlayer implements AbstractPlayer { | |
| private String marker; | |
| private Player opponent; | |
| public AbstractAlphaBeta(Player player) { | |
| this.marker = player.getMarker(); | |
| this.opponent = player.getOpponent(); | |
| } |