Define a class Course
that can be used to represent courses. Two arguments must be passed when creating a new course (Course
): i) the unique identifier (int
) of the course and ii) the name (str
) of the course.
Define a class Student
that can be used to represent students. Four arguments must be passed when creating a new student (Student
): i) the unique identifier (int
) of the student, ii) the first name (str
) of the student, iii) the last name (str
) of the student and iv) the date of birth (datetime.date
) of the student. Students (Student
) must support at least the following methods:
A method age
that takes no arguments. The method must return the current age (int
) of the student.
A method enroll
that takes a course (Cursus
). The method must make sure that student the student keeps track that he has enrolled for the given course. The method must return a reference to the object on which it was called.
A method courses
that takes no arguments. The method must return a set
of all courses (Course
) in which the student has enrolled.
If a course (Course
) or a student (Student
) is passed to the builtin functions repr
or str
, the functions must return a string representation (str
) of the course or the student that is formatted as in the example below.
>>> astronomy = Course(238273, 'Astronomy')
>>> astronomy
Course(238273, 'Astronomy')
>>> print(astronomy)
Course(238273, 'Astronomy')
>>> import datetime
>>> harry = Student(29839339, 'Harry', 'Potter', datetime.date(1980, 7, 31))
>>> harry
Student(29839339, 'Harry', 'Potter', datetime.date(1980, 7, 31))
>>> print(harry)
Potter, Harry
>>> harry.age()
39
>>> harry.courses()
set()
>>> harry.enroll(charms)
Student(29839339, 'Harry', 'Potter', datetime.date(1980, 7, 31))
>>> harry.courses()
{Course(983448, 'Charms')}
>>> harry.enroll(charms).enroll(dark_arts).enroll(defence_against_dark_arts).courses()
{Course(746473, 'Dark Arts'), Course(983448, 'Charms'), Course(462763, 'Defence Against Dark Arts')}