-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbird_class.py
More file actions
96 lines (68 loc) · 2.27 KB
/
bird_class.py
File metadata and controls
96 lines (68 loc) · 2.27 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
82
83
84
85
86
87
88
89
90
91
92
93
94
'''
Bird has features name and amount of eggs. Amount of eggs has to be between 1 and 10.
Migratory has special features: there is attribute named country that is the destination country and month when the migration mainly occurs.
Country name has to begin with a cap and its length has to be between 5 to 20. Month has to be between 1 and 12.
'''
class Bird:
def __init__(self, name, eggs):
self.name = name
if eggs >= 1 and eggs <= 10:
self.eggs = eggs
else:
self.eggs = "Egg amount not correct"
def getInfo(self):
bird_info = f"Name: {self.name} \nEggs: {self.eggs}"
return bird_info
def getBirdName(self):
return self.name
def getEggs(self):
return self.eggs
def setBirdName(self, name):
self.name = name
def setEggs(self, eggs):
self.eggs = eggs
class Migratory:
def __init__(self, country, month):
if len(country) >= 5 and len(country) <= 20 and country[0].isupper() == True:
self.country = country
else:
self.country = "Incorrect country"
if month >= 1 and month <= 12:
self.month = month
else:
self.month = "Month has to be between 1 and 12"
def getInfoMigratory(self):
migratory_info = f"Country: {self.country} \nMonth: {self.month}"
return migratory_info
def getCountry(self):
return self.country
def getMonth(self):
return self.month
def setCountry(self, country):
self.country = country
def setMonth(self, month):
self.month = month
eggs1 = 11
eggs2 = 5
country1 = "test"
country2 = "Test"
country3 = "Spain"
country4 = "Hsjlkhjdfjkhsdfjksdhdjfksjdhflk"
country5 = "Kshrjghrulopahdgtreo"
month1 = 0
month2 = 6
month3 = 22
bird = Bird("Kalle", eggs1)
print(bird.getInfo())
bird = Bird("Matti", eggs2)
print(bird.getInfo())
bird_mig = Migratory(country1, month1)
print(bird_mig.getInfoMigratory())
bird_mig = Migratory(country2, month2)
print(bird_mig.getInfoMigratory())
bird_mig = Migratory(country3, month3)
print(bird_mig.getInfoMigratory())
bird_mig = Migratory(country4, month3)
print(bird_mig.getInfoMigratory())
bird_mig = Migratory(country5, month2)
print(bird_mig.getInfoMigratory())