-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
107 lines (90 loc) · 3.45 KB
/
main.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import time
import Aqua
def demo(myaqua):
myaqua.add_animal("scalarfish1", 4, 10, 10, 1, 0, 'sc')
myaqua.add_animal("molyfish2", 12, 35, 15, 0, 1, 'mo')
myaqua.add_animal("shrimpcrab1", 3, 20, myaqua.aqua_height - 4, 1, 0, 'sh')
myaqua.add_animal("ocypodecrab2", 13, 41, myaqua.aqua_height - 5, 0, 0, 'oc')
myaqua.print_board()
a = myaqua.get_all_animal()
for i in range(120):
myaqua.next_turn()
if myaqua.turn % 5 == 0:
myaqua.feed_all()
myaqua.print_board()
time.sleep(0.5)
return None
def add_animal(myaqua):
choice = 0
while not 1 <= choice <= 4:
print("Please select:")
print("1. Scalare")
print("2. Moly")
print("3. Ocypode")
print("4. Shrimp")
choice = int(input("What animal do you want to put in the aquarium?"))
name = input("Please enter a name:")
age = 0
while not 1 <= age <= 100:
age = int(input("Please enter age:"))
success = False
while not success:
x, y = 0, 0
while not 1 <= x <= (myaqua.aqua_width - 1):
x = int(input("Please enter an X axis location (1 - %d):" % (myaqua.aqua_width - 1)))
if choice == 1 or choice == 2:
while not Aqua.WATERLINE <= y <= (myaqua.aqua_height - 1):
y = int(input("Please enter an Y axis location (%d - %d):" % (Aqua.WATERLINE, myaqua.aqua_height - 1)))
directionH, directionV = -1, -1
while not (directionH == 0 or directionH == 1):
directionH = int(input("Please enter horizontal direction (0 for Left, 1 for Right):"))
if choice == 1 or choice == 2:
while not (directionV == 0 or directionV == 1):
directionV = int(input("Please enter vertical direction (0 for Down, 1 for Up):"))
if choice == 1:
success = myaqua.add_animal(name, age, x, y, directionH, directionV, 'sc')
elif choice == 2:
success = myaqua.add_animal(name, age, x, y, directionH, directionV, 'mo')
elif choice == 3:
success = myaqua.add_animal(name, age, x, myaqua.aqua_height - 5, directionH, 0, 'oc')
else:
success = myaqua.add_animal(name, age, x, myaqua.aqua_height - 4, directionH, 0, 'sh')
return None
if __name__ == '__main__':
width = 0
height = 0
print('Welcome to "The OOP Aquarium"')
while width < 40:
width = int(input("The width of the aquarium (Minimum 40): "))
while height < 25:
height = int(input("The height of the aquarium (Minimum 25): "))
myaqua = Aqua.Aqua(width, height)
while True:
choice = 0
while not 1 <= choice <= 7:
print("Main menu")
print("-" * 30)
print("1. Add an animal")
print("2. Drop food into the aquarium")
print("3. Take a step forward")
print("4. Take several steps")
print("5. Demo")
print("6. Print all")
print("7. Exit")
choice = int(input("What do you want to do?"))
if choice == 1:
add_animal(myaqua)
elif choice == 2:
myaqua.feed_all()
elif choice == 3:
myaqua.next_turn()
elif choice == 4:
myaqua.several_steps()
elif choice == 5:
demo(myaqua)
elif choice == 6:
myaqua.print_all()
else:
print("Bye bye")
exit()
myaqua.print_board()