def queryNumberOfColors(self): """Ask the user how many colors to use for secret pattern.""" inputOptions = [] for i in range(2, len(self._colorNames) + 1): inputOptions.append(str(i)) dialog = Dialog('How many colors are available?', inputOptions, 'Number of color', 500) self._numberOfColors = int(dialog.display()) return self._numberOfColors
def queryNewGame(self): """Offer the user a new game. Return True if accepted, False otherwise.""" dialog = Dialog('Would you like to play again?', ['Yes', 'No'], 'Again?') return dialog.display() == 'Yes'
def queryNumberOfTurns(self): """Ask the user maximum number of guesses to be allowed.""" dialog = Dialog('How many turns are allowed?', ['5', '10', '15', '20'], 'Number of turns') return int(dialog.display())
def queryLengthOfPattern(self): """Ask the user how many pegs in the secret pattern.""" dialog = Dialog('How many pegs are in the secret?', ['4', '6', '8', '10'], 'Length of pattern') return int(dialog.display())