Odstranit u5/kindergarted-garden.py
This commit is contained in:
parent
fb8019cefa
commit
c23121f1fb
@ -1,40 +0,0 @@
|
|||||||
class NoSuchStudentException(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class Garden:
|
|
||||||
DEFAULT_STUDENTS = ["Alice", "Bob", "Charlie", "David","Eve", "Fred", "Ginny", "Harriet", "Ileana", "Joseph", "Kincaid", "Larry"]
|
|
||||||
|
|
||||||
PLANT_MAP ={
|
|
||||||
'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)
|
|
||||||
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