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
(def options-list (atom {:first-marker "first-marker" :second-marker "second-marker" :board "board" :first-type "first-type" :second-type "second-type"})) | |
(def add-to-options (fn [symbol option] (swap! options-list assoc-in [symbol] option))) | |
(defn get-first-player [] | |
(ui/prompt-for-piece)) | |
(defn get-second-player [] | |
(ui/prompt-for-ai-piece)) |
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
(it "should get the first player's piece choice" | |
(with-redefs [read-line (constantly "X")] | |
(should= {:first-marker, "X"} | |
(get-first-player)))) |
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 abstract class GameWinnerDetector { | |
protected String findBoardWinner(int boardLength) { | |
for (int index = 0; index < boardLength; index++) { | |
addGamePiecesToList(index); | |
} | |
return checkIfWinnerExists(); | |
} |
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
private String checkColumns() { | |
int boardLength = board.getMatrix().length; | |
int maxIndexValue = boardLength - 1; | |
String[][] lineValues = new String[boardLength][boardLength]; | |
for (int columnIndex = 0; columnIndex < boardLength; columnIndex++) { | |
for (int index = 0; index < boardLength; index++) { | |
lineValues[columnIndex][index] = getValueAtIndex(columnIndex, maxIndexValue - index); | |
} | |
} |
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
private String checkColumns() { | |
for (int i = 0; i < board.getMatrix().length; i++) { | |
String value = board.getMatrix()[i][0]; | |
if (value == "*") { | |
continue; | |
} | |
for (int j = 1; j < board.getMatrix()[i].length; j++) { | |
String currentSpace = board.getMatrix()[i][j]; | |
if (currentSpace == "*" || !currentSpace.equals(value)) { | |
break; |
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
# Choice Interface with command method | |
public interface Choice { | |
public int getConfigurationChoice(); | |
} | |
# Class implementation of Interface | |
public class BoardSize implements Choice { |
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
# GameRunner before | |
public class GameRunner { | |
public static void main(String[] args) { | |
SetUpGame setup = new SetUpGame(); | |
setup.startGame(); | |
} | |
} |
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 SetUpTicTacToeGameTest { | |
private SetUpTicTacToeGame setupTest; | |
@Test | |
public void checkThatAllObjectsAreInitialized() { | |
List<Integer> userChoices= new ArrayList<>(); | |
userChoices.add(3); | |
userChoices.add(2); | |
userChoices.add(1); |
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 SetUpTicTacToeGame { | |
private List<Integer> userChoices; | |
private Board board; | |
private GameParticipants player1; | |
private GameParticipants player2; | |
private PrintStream output; | |
private Scanner input; | |
private UserInterface ui; | |
private BoardRulesInterface boardRules; | |
private Game game; |
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 ParticipantChoice implements Choice { | |
private CommandLineInterface ui; | |
private int playerOption; | |
private ChoiceValidator choiceValidator; | |
public ParticipantChoice(CommandLineInterface ui) { | |
this.ui = ui; | |
} | |
public List<String> addValidChoices() { |