no
This commit is contained in:
parent
8a858776fc
commit
5b6b8a308d
38
u5/kindergarten_garden.py
Normal file
38
u5/kindergarten_garden.py
Normal file
@ -0,0 +1,38 @@
|
||||
class NoSuchStudentException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Garden:
|
||||
def __init__(self, diagram, students=None):
|
||||
rows = diagram.split("\n")
|
||||
self.row1 = rows[0]
|
||||
self.row2 = rows[1]
|
||||
|
||||
self.students = [
|
||||
"Alena", "Boris", "Cyril", "Daniel", "Eva", "František",
|
||||
"Gitka", "Helena", "Ivana", "Jozef", "Karol", "Ladislav"
|
||||
]
|
||||
|
||||
self.plant_names = {
|
||||
"G": "Tráva",
|
||||
"C": "Ďatelina",
|
||||
"R": "Reďkovky",
|
||||
"V": "Fialky"
|
||||
}
|
||||
|
||||
def plants(self, student):
|
||||
index = self.students.index(student)
|
||||
pos = index * 2
|
||||
|
||||
letters = [
|
||||
self.row1[pos],
|
||||
self.row1[pos + 1],
|
||||
self.row2[pos],
|
||||
self.row2[pos + 1]
|
||||
]
|
||||
|
||||
result = []
|
||||
for letter in letters:
|
||||
result.append(self.plant_names[letter])
|
||||
|
||||
return result
|
||||
Loading…
Reference in New Issue
Block a user