This repository was archived by the owner on Aug 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexercise-general-week-05-06.py
More file actions
81 lines (57 loc) · 1.7 KB
/
Copy pathexercise-general-week-05-06.py
File metadata and controls
81 lines (57 loc) · 1.7 KB
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
from enum import Enum
##---------------------------------------------------------------------------##
#
#
#
##---------------------------------------------------------------------------##
class RiskLevel(Enum):
WILD = 1
SAFE = 2
RISKY = 3
##---------------------------------------------------------------------------##
class Animal:
name: str = None
risk = RiskLevel.RISKY
def __init__(self, name: str, risk_level=RiskLevel.RISKY) -> None:
self.name = name
self.risk = risk_level
def __str__(self) -> str:
return "{}:({}>{}>{})".format(
self.name, self.__class__.__name__, self.risk.name, self.movement()
)
def __repr__(self) -> str:
return self.__str__()
def movement(self):
pass
##---------------------------------------------------------------------------##
class Mamal(Animal):
def movement(self):
return "Walk"
class Bird(Animal):
def movement(self):
return "Fly"
class Fish(Animal):
def movement(self):
return "Swim"
##---------------------------------------------------------------------------##
# تمرین ۱
#
#
##---------------------------------------------------------------------------##
# تمرین ۲
#
#
##---------------------------------------------------------------------------##
# تمرین ۳
#
#
my_animals = []
##---------------------------------------------------------------------------##
my_animals.append(Mamal("Lion", RiskLevel.WILD))
my_animals.append(Bird("BlueJay", RiskLevel.SAFE))
my_animals.append(Bird("Hen"))
my_animals.append(Bird("Rooster"))
my_animals.append(Fish("Dolphin", RiskLevel.SAFE))
print(my_animals)
# EXERCISE:
# Save to file