Odstranit u5/kindergarten-garden.py
This commit is contained in:
parent
db4a51b184
commit
acbf746aa9
@ -1,44 +0,0 @@
|
||||
class NoSuchStudentException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Garden:
|
||||
DEFAULT_STUDENTS = [
|
||||
"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'
|
||||
}
|
||||
|
||||
def __init__(self, diagram, students=None):
|
||||
if students is None:
|
||||
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."
|
||||
)
|
||||
|
||||
i = self.students.index(student)
|
||||
c1 = i * 2
|
||||
c2 = i * 2 + 1
|
||||
|
||||
student_plants = [
|
||||
self.r[0][c1],
|
||||
self.r[0][c2],
|
||||
self.r[1][c1],
|
||||
self.r[1][c2]
|
||||
]
|
||||
|
||||
return [self.PLANT_MAP[code] for code in student_plants]
|
||||
Loading…
Reference in New Issue
Block a user