-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsudoku.py
32 lines (23 loc) · 876 Bytes
/
sudoku.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from sys import argv # Import object to get list of arguments entered in the terminal
from terminal import Terminal # Import Terminal class
from gui import GUI # Import GUI class
def print_usage(): # Print how to run the game in terminal
print("""Welcome to Sudoku
To start the program in terminal:
ENTER [python] sudoku.py t
To start the program in GUI:
ENTER [python] sudoku.py g""")
def main():
if len(argv) != 2: # If number of arguments is not 2
print_usage()
return
if argv[1] == "t": # Run terminal if 't' option used
game = Terminal()
elif argv[1] == "g": # Run GUI if 'g' option used
game = GUI()
else: # Otherwise print program usage
print_usage()
return
game.run() # Start the game
if __name__ in "__main__": # Driver code
main()