diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..cdde960 Binary files /dev/null and b/.DS_Store differ diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..e7e9d11 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d1e22ec --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..2cbf479 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/simon_game.iml b/.idea/simon_game.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/simon_game.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CONTROLLER/.DS_Store b/CONTROLLER/.DS_Store new file mode 100644 index 0000000..d3f79d8 Binary files /dev/null and b/CONTROLLER/.DS_Store differ diff --git a/CONTROLLER/.idea/.gitignore b/CONTROLLER/.idea/.gitignore new file mode 100644 index 0000000..e7e9d11 --- /dev/null +++ b/CONTROLLER/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml diff --git a/CONTROLLER/.idea/CONTROLLER.iml b/CONTROLLER/.idea/CONTROLLER.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/CONTROLLER/.idea/CONTROLLER.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/CONTROLLER/.idea/inspectionProfiles/profiles_settings.xml b/CONTROLLER/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/CONTROLLER/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/CONTROLLER/.idea/misc.xml b/CONTROLLER/.idea/misc.xml new file mode 100644 index 0000000..d1e22ec --- /dev/null +++ b/CONTROLLER/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/CONTROLLER/.idea/modules.xml b/CONTROLLER/.idea/modules.xml new file mode 100644 index 0000000..57ffd6b --- /dev/null +++ b/CONTROLLER/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/CONTROLLER/.idea/vcs.xml b/CONTROLLER/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/CONTROLLER/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CONTROLLER/README.md b/CONTROLLER/README.md index e69de29..5768787 100644 --- a/CONTROLLER/README.md +++ b/CONTROLLER/README.md @@ -0,0 +1,5 @@ +# folder controller +# in this folder +three file one file main for run program simon game +i use for this project "object attributes and method in pyhon" +i have create two files for two class and i create and instancies objet diff --git a/CONTROLLER/__pycache__/main.cpython-38.pyc b/CONTROLLER/__pycache__/main.cpython-38.pyc new file mode 100644 index 0000000..b146e4c Binary files /dev/null and b/CONTROLLER/__pycache__/main.cpython-38.pyc differ diff --git a/CONTROLLER/__pycache__/player.cpython-36.pyc b/CONTROLLER/__pycache__/player.cpython-36.pyc index e3c6f31..d658c50 100644 Binary files a/CONTROLLER/__pycache__/player.cpython-36.pyc and b/CONTROLLER/__pycache__/player.cpython-36.pyc differ diff --git a/CONTROLLER/__pycache__/player.cpython-38.pyc b/CONTROLLER/__pycache__/player.cpython-38.pyc new file mode 100644 index 0000000..c12910a Binary files /dev/null and b/CONTROLLER/__pycache__/player.cpython-38.pyc differ diff --git a/CONTROLLER/__pycache__/player_game.cpython-36.pyc b/CONTROLLER/__pycache__/player_game.cpython-36.pyc index f43a411..8ccaa04 100644 Binary files a/CONTROLLER/__pycache__/player_game.cpython-36.pyc and b/CONTROLLER/__pycache__/player_game.cpython-36.pyc differ diff --git a/CONTROLLER/__pycache__/program.cpython-36.pyc b/CONTROLLER/__pycache__/program.cpython-36.pyc index 56cba41..0a1750d 100644 Binary files a/CONTROLLER/__pycache__/program.cpython-36.pyc and b/CONTROLLER/__pycache__/program.cpython-36.pyc differ diff --git a/CONTROLLER/__pycache__/program.cpython-38.pyc b/CONTROLLER/__pycache__/program.cpython-38.pyc new file mode 100644 index 0000000..92655be Binary files /dev/null and b/CONTROLLER/__pycache__/program.cpython-38.pyc differ diff --git a/CONTROLLER/main.py b/CONTROLLER/main.py index 2204d26..a6080f0 100644 --- a/CONTROLLER/main.py +++ b/CONTROLLER/main.py @@ -2,43 +2,33 @@ # coding: utf-8 from player import * from program import * -from player_game import * if __name__ == "__main__": print("Hello start game") -player = Player() -#ask method name entry in player.py -player.name_entry() -#ask method level choice for user select level -player.level_choice() -game = Program() -#result_lists = True -while 1: + player = Player() + #ask method name entry in player.py + player.name_entry() + #ask method level choice for user select level + player.level_choice() + game = Program() + #result_lists = True + restart = True result_lists = True - if result_lists == True: - #ask method to use level in program + while result_lists != False: + # ask method to use level in program game.get_level(player.level) - #ask method random number + # ask method random number game.random_choice() - #ask method for save number in list + # ask method for save number in list game.add_list_choice() - #method for clear prompt + # method for clear prompt game.clear_terminal() - player_game = Player_entry() - #ask method for player entry number - player_game.player_entry() - #method for add to list number of user entry - player_game.add_user_list() - #print(Player_entry) - #print(player_game.__dict__) - #method for compare list player and program list - game.compare_list(player_game.player_list, result_lists) - game.clear_user_list() + # ask method for compare number user and program list + game.compare_list(player.player_numbers, result_lists) + + #if result_lists == False: + #game.play_again_choice() + if restart == True: + __name__ == "__main__" - if result_lists == False: - game.play_again() - - - - diff --git a/CONTROLLER/player.py b/CONTROLLER/player.py index c154f8f..1299c82 100644 --- a/CONTROLLER/player.py +++ b/CONTROLLER/player.py @@ -1,11 +1,13 @@ import os from time import sleep +from program import * class Player: """method for initialyse name""" def __init__(self): self.name = "" - self.level = None - + self.level = None + self.player_numbers = 0 + """method for ask and save name entry""" def name_entry(self): name = input("enter your name :") @@ -23,4 +25,6 @@ def level_choice(self): sleep(2) os.system("clear") return level - #print("{} you choice level {} start game ..........".format(self.name,level)) + + + diff --git a/CONTROLLER/player_game.py b/CONTROLLER/player_game.py deleted file mode 100644 index 810b246..0000000 --- a/CONTROLLER/player_game.py +++ /dev/null @@ -1,27 +0,0 @@ -from program import * -class Player_entry: - """class for player entry and list for compare with program list""" - def __init__(self): - self.player_list = [] - self.player_numbers = 0 - - def player_entry(self): - """save number entry user """ - player_numbers = int(input("enter numbers ......:")) - self.player_numbers = player_numbers - - def add_user_list(self): - """save in list number entry user""" - #print(self.player_list) - self.player_list.append(self.player_numbers) - player_list = self.player_list - #print(player_list) - return player_list - - - - - - - - \ No newline at end of file diff --git a/CONTROLLER/program.py b/CONTROLLER/program.py index 4f045bb..d5d547f 100644 --- a/CONTROLLER/program.py +++ b/CONTROLLER/program.py @@ -1,34 +1,36 @@ from random import * import os from time import sleep -from player_game import * +from player import * +from main import * + class Program: """class for program controller """ def __init__(self): self.program_list = [] - self.user_list = [] self.numbers_program = None self.number_user = 0 self.level_choice = None - #self.result_lists = None + self.play_again = None + self.result_lists = None + self.player_numbers = 0 def get_level(self, level): """method for save level choice user""" self.level_choice = level - #print(self.level_choice) def random_choice(self): """method for choice random number """ if self.level_choice == 3: - #select number betwen 1 and 100 + # select number betwen 1 and 100 self.numbers_program = randrange(1, 100) if self.level_choice == 2: - #select number betwen 1 and 20 + # select number betwen 1 and 20 self.numbers_program = randrange(1, 20) if self.level_choice == 1: - #select number between 1 and 10 + # select number between 1 and 10 self.numbers_program = randrange(1, 10) def add_list_choice(self): @@ -55,31 +57,38 @@ def clear_terminal(self): sleep(1) os.system("clear") - def compare_list(self, player_list, result_lists): + def compare_list(self, player_numbers, program_lists): """compare list user and list program """ - - for i in range(0, len(self.program_list)): - if self.program_list[i] == player_list[i]: - result_lists = True - return result_lists - print(result_lists) - - else: + #player_numbers = int(input("enter numbers ......:")) + for i in self.program_list: + self.player_numbers = self.player_numbers_entry() + if self.player_numbers != i: result_lists = False - return result_lists - print(result_lists) - def clear_user_list(self): - """clear user list number for again manche""" - player_list = [] - def play_again(): + pursuite = self.play_again_choice() + """else: + result_lists = True + return result_lists""" + + def player_numbers_entry(self): + """method for verify if number is an integer""" + try: + self.player_numb = int(input("enter numbers........:")) + except: + print("not good") + return self.player_numb + + def play_again_choice(self): """ask to player if his play again""" - while play_again_choice != "yes" and play-again != "no": - play_again_choice = input("do you want to play again enter yes or no :") - if play_again_choice == "yes": - __name__ == "__main__" + while self.play_again != "yes" or self.play_again != "no": + self.play_again = input("do you want to play again enter yes or no :") + if self.play_again == "yes": + restart = True + return restart + else: - break + print("good bye") + exit() \ No newline at end of file diff --git a/README.md b/README.md index e69de29..18c93bb 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,4 @@ +#python game "simon" +this an model of pyhton game "simon" +i have create this game for project in python +i use class method object and attributes for this game