This commit is contained in:
Oleksandr Mateshchuk 2026-10-13 11:59:18 +00:00
parent eec0ad030c
commit f12653c5d9

View File

@ -1,32 +1,35 @@
```python
class NoSuchStudentException(Exception):
pass
class Garden:
DEFAULT_STUDENTS = [
"Alice", "Bob", "Charlie", "David",
"Eve", "Fred", "Ginny", "Harriet",
"Ileana", "Joseph", "Kincaid", "Larry"
"Alena", "Boris", "Cyril", "Daniel",
"Eva", "František", "Gitka", "Helena",
"Ivana", "Jozef", "Karol", "Ladislav"
]
PLANT_MAP = {
'G': 'tráva',
'C': 'ďatelina',
'R': 'reďkovky',
'V': 'fialky'
'G': 'Tráva',
'C': 'Ďatelina',
'R': 'Reďkovky',
'V': 'Fialky'
}
def __init__(self, diagram, students=None):
if students is None:
self.students = sorted(self.DEFAULT_STUDENTS)
self.students = self.DEFAULT_STUDENTS.copy()
else:
self.students = sorted(students)
self.r = diagram.splitlines()
def plants(self, student):
if student not in self.students:
raise NoSuchStudentException(f"Student '{student}' is not assigned a plot.")
raise NoSuchStudentException(
f"Student '{student}' is not assigned a plot."
)
i = self.students.index(student)
c1 = i * 2
@ -39,4 +42,5 @@ class Garden:
self.r[1][c2]
]
return [self.PLANT_MAP[code] for code in student_plants]
return [self.PLANT_MAP[code] for code in student_plants]
```