Отсутствует 1 обязательный позиционный аргумент: 'отдел'

    class Student:
    def __init__(self, name, student_number):
        self.name = name
        self.student_number = student_number
        self.classes = {}

    def enrol(self, course_running):
        self.classes.append(course_running)
        course_running.add_student(self)


class Department:
    def __init__(self, name, department_code):
        self.name = name
        self.department_code = department_code
        self.courses = {}

    def add_course(self, description, course_code, credits):
        self.courses[course_code] = Course(description, course_code, credits)
        return self.courses[course_code]


class Course:
    def __init__(self, description, course_code, credits, department):
        self.description = description
        self.course_code = course_code
        self.credits = credits
        self.department = department
        self.department.add_course(self)

        self.runnings = []

    def add_running(self, year):
        self.runnings.append(CourseRunning(self, year))
        return self.runnings[-1]


class CourseRunning:
    def __init__(self, course, year):
        self.course = course
        self.year = year
        self.students = []

    def add_student(self, student):
        self.students.append(student)


maths_dept = Department("Mathematics and Applied Mathematics", "MAM")
mam1000w = maths_dept.add_course("Mathematics 1000", "MAM1000W", "1")
mam1000w_2013 = mam1000w.add_running(2013)

bob = Student("Bob", "Smith")
bob.enrol(mam1000w_2013)

Здравствуйте, не мог бы кто-нибудь объяснить, почему этот код не работает? Сообщение об ошибке, которое я получаю, следующее:

Traceback (последний последний вызов): File "G:\Shares\Website\Development\Intranet\HealthcareProject4\HealthcareProject4\Population\Schools.py", line 49, in mam1000w = maths_dept.add_course("Mathematics 1000", "MAM1000W", "1") File "G:\Shares\Website\Development\Intranet\HealthcareProject4\HealthcareProject4\Population\Schools.py", line 19, in add_course self.courses[course_code] = Course(description, course_code, credits) TypeError: init() missing 1 required positional argument: 'department' Нажмите любую клавишу для продолжения. . .

Следуя предложениям в комментариях ниже, вторая ошибка, которую я получаю, следующая:

Traceback (последний последний вызов): File "G:\Shares\Website\Development\Intranet\HealthcareProject4\HealthcareProject4\Population\Schools.py", line 49, in mam1000w = maths_dept.add_course("Mathematics 1000", "MAM1000W", "1", "Mathematics and Applied Mathematics") Файл "G:\Shares\Website\Development\Intranet\HealthcareProject4\HealthcareProject4\Population\Schools.py", строка 19, in add_course self.courses[course_code] = Course(description, course_code, credits, department) File "G:\Shares\Website\Development\Intranet\HealthcareProject4\HealthcareProject4\Population\Schools.py", line 29, in init self.department.add_course(self) AttributeError: объект 'str' не имеет атрибута 'add_course' Нажмите любую клавишу, чтобы продолжить. . .

Вернуться на верх