class easy_test(unittest.TestCase): solution = None def setUp(self): self.solution = Easy() def test_two_sum_case1(self): nums = [2, 7, 11, 15] target = 9 self.assertEqual(self.solution.two_sum(nums, target), [0, 1]) def test_two_sum_case2(self): nums = [2, 7, 11, 15] target = 6 self.assertEqual(self.solution.two_sum(nums, target), []) def test_two_sum_case3(self): nums = [] target = 10 self.assertEqual(self.solution.two_sum(nums, target), []) def test_two_sum_case4(self): nums = [3, 2, 4] target = 6 self.assertEqual(self.solution.two_sum(nums, target), [1, 2])
def Restart1(self): re1 = tkMessageBox.askquestion("Restart", "Are You Sure,You Want To Restart ?") if ( re1 == 'yes' ): #if player wants to play again then it returns to the main window or else it destroys the window. self.forgetframe() Easy.__init__(self, root) else: pass
def level1(self): #Forgets everything and opens 8 by 8 game self.frame.grid_forget() self.label_minesweeper.grid_forget() self.level1_button.grid_forget() self.level2_button.grid_forget() self.startgame = Button( self.frame, command=instruction) #Displays Instructions button. self.startgame.grid(row=2, column=0, columnspan=9) self.Quit_button.grid_forget() self.Inst_button.grid_forget() global root Easy.__init__(self, root)
def create_player(self, player_type, symbol): if player_type == 'user': return User(symbol, self.board) elif player_type == 'easy': return Easy(symbol, self.board) elif player_type == 'medium': return Medium(symbol, self.board) elif player_type == 'hard': return Hard(symbol, self.board)
def get_coords(self): lines = self.board.get_lines(self.board.get_full_board()) player = self.coords_to_full_line(lines, self.symbol, True) opponent = self.coords_to_full_line(lines, self.symbol, False) if player is not None: return player elif opponent is not None: return opponent else: return Easy.get_random_coords(self.board)
def win(self, b): win = tkMessageBox.askquestion("Game over!", "You Won! Do you want to play again?") global root if ( win == 'yes' ): #if player wants to play again then it returns to the main window or else it destroys the window. self.forgetframe() if (b == 1): Easy.__init__(self, root) else: Hard.__init__(self, root) else: sure2 = tkMessageBox.askquestion("Game over!", "Are you sure you want to exit?") if (sure2 == 'yes'): tkMessageBox.showinfo("!!! Bye !!!", "Thanks for playing!!") root.destroy() else: self.forgetframe() self.__init__(self)
pygame.mixer.music.load('01 BGM #01.mp3') pygame.mixer.music.play(-1) # size of the grid width = 16 height = 16 margin = 5 text = pygame.font.SysFont('Comic Sans MS', 10, True) lev = "Game on" num_bombs = 40 time_count = [] grid = [] easy = [Easy()] medium = [Medium()] difficult = [Difficult()] level = [lev] def ModePressed(): pass def delObjects(): global grid global time_count global mode global lev global p_pressed
def setUp(self): self.solution = Easy()