Created
March 24, 2015 15:18
-
-
Save pumpkincouture/7586b33f3252820c2408 to your computer and use it in GitHub Desktop.
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 { | |
private CommandLineInterface ui; | |
private int boardChoice; | |
private ChoiceValidator choiceValidator; | |
public BoardSize(CommandLineInterface ui) { | |
this.ui = ui; | |
} | |
@Override | |
public int getConfigurationChoice() { | |
ui.promptForBoardSize(); | |
validateBoardSizeChoice(ui.captureChoice()); | |
return boardChoice; | |
} | |
} | |
# New Input Collector | |
public class MenuFactory { | |
private List<Integer> gameValues = new ArrayList<>(); | |
public void collectUserInput(List<Choice> gameOptions) { | |
for (Choice choice : gameOptions) { | |
gameValues.add(choice.getConfigurationChoice()); | |
} | |
} | |
public List<Integer> getUserValues() { | |
return gameValues; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment