Skip to content

Instantly share code, notes, and snippets.

View pumpkincouture's full-sized avatar

Sylwia Bridges pumpkincouture

View GitHub Profile
(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))
(it "should get the first player's piece choice"
(with-redefs [read-line (constantly "X")]
(should= {:first-marker, "X"}
(get-first-player))))
public abstract class GameWinnerDetector {
protected String findBoardWinner(int boardLength) {
for (int index = 0; index < boardLength; index++) {
addGamePiecesToList(index);
}
return checkIfWinnerExists();
}
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);
}
}
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;
# Choice Interface with command method
public interface Choice {
public int getConfigurationChoice();
}
# Class implementation of Interface
public class BoardSize implements Choice {
# GameRunner before
public class GameRunner {
public static void main(String[] args) {
SetUpGame setup = new SetUpGame();
setup.startGame();
}
}
public class SetUpTicTacToeGameTest {
private SetUpTicTacToeGame setupTest;
@Test
public void checkThatAllObjectsAreInitialized() {
List<Integer> userChoices= new ArrayList<>();
userChoices.add(3);
userChoices.add(2);
userChoices.add(1);
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;
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() {