def test_check(): check = Check() check.letter_guessed = "a" word = "frog" spaces = ["_", "_", "_", "_"] check.check(word, spaces) assert check.incorrect_guesses == 1
from check import Check someProxies = """ 182.254.153.54:80 117.177.243.53:8080 39.171.108.213:8123 117.177.243.15:8080 180.208.78.49:80 222.88.236.236:843 58.220.2.141:80 58.220.2.140:80 120.198.236.10:80 58.220.2.136:80 58.220.2.133:80 222.88.236.234:81 202.194.96.46:80 180.97.185.35:10001 58.220.2.142:80 116.228.80.186:8080 220.248.224.242:8089 58.220.2.135:80 115.159.5.247:80 111.12.83.27:80 106.38.251.62:8088 203.148.12.132:8000 """ if __name__ == "__main__": ck = Check() successProxies = ck.check(someProxies.split('\n')) print "\n".join(successProxies)
class Director: '''A code outline for the director of the jumper game. The purpose of this class is to control the suquence of play Stereotype: Controller Attributes: puzzle (Puzzle): An instance of the class of objects known as Puzzle. jumper (Jumper): An instance of the class of objects known as Jumper. check (Check): An instance of the class of objects known as Check. keep_playing (boolean): Whether or not the game can continue. ''' def __init__(self): """The class constructor. Args: self (Director): an instance of Director. """ self.puzzle = Puzzle() self.jumper = Jumper() self.check = Check() self.keep_playing = True def start_game(self): """Starts the game loop to control the sequence of play. Args: self (Director): an instance of Director. """ keep_playing = True while keep_playing: self.puzzle.print_spaces() self.jumper.print_jumper(self.check.incorrect_guesses) self.guess_and_check() print("\n\n") keep_playing = self.is_game_still_going() def guess_and_check(self): '''This asks player for guess and updates game based on guess Args: self (Director): An instance of Director. ''' self.check.guess() self.puzzle.spaces = self.check.check(self.puzzle.chosen_word, self.puzzle.spaces) def is_game_still_going(self): '''This checks if the player has won or lost Args: self (Director): An instance of Director. ''' if self.check.incorrect_guesses == 4: self.jumper.dead_head() self.jumper.print_jumper(self.check.incorrect_guesses) print("You Lose") return False elif "_" not in self.puzzle.spaces: print("You Win!") self.puzzle.print_spaces() return False else: return True