user28576550
user28576550

Reputation: 1

TypeError: Technician.__init__() missing 1 required positional argument: 'specialization'

I'm trying to do my homework on object-oriented programming but I get a weird error. tried restarting VSCode or changing names.

Objective: To develop an employee management system that demonstrates multiple inheritance, encapsulation, and polymorphism in Python. The system should manage various types of activities, including managers and technical specialists, and provide opportunities for expansion and addition of new roles.

class Employee: #parent class
    def __init__(self, name, id):
        self.name = name
        self.id = id

class Manager(Employee):
    def __init__(self, name, id, department):
        super().__init__(name, id)
        self.department = department

class Technician(Employee):
    def __init__(self, name, id, specialization):
        super().__init__(name, id)
        self.specialization = specialization

class TechManager(Manager, Technician):
    def __init__(self, name, id, department, specialization):
        Manager.__init__(self, name, id, department)
        Technician.__init__(self, name, id, specialization)
        self.subordinates = []

    def add_employee(self, employee):
        self.subordinates.append(employee)

    def get_team_info(self):
        subordinates_info = [employee.get_info() for employee in self.team]
        print(f"Список подчиненных:\n" + "\n".join(subordinates_info))

employee1 = Employee("Сергей", 1)
manager1 = Manager("Денис", 2, "ит")
technician1 = Technician("Петр", 3, "ии")
techManager1 = TechManager("Андрей", 4, "ит", "ии")

I get this error message:

PS C:\Users\EvoTechPC> & C:/Users/EvoTechPC/AppData/Local/Microsoft/WindowsApps/python3.11.exe c:/Users/EvoTechPC/Desktop/учеба/ввит/lab7/Main.py
Traceback (most recent call last):
  File "c:\Users\EvoTechPC\Desktop\учеба\ввит\lab7\Main.py", line 41, in <module>
    techManager1 = TechManager("Андрей", 4, "ит", "ии")
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\EvoTechPC\Desktop\учеба\ввит\lab7\Main.py", line 27, in __init__
    Manager.__init__(self, name, id, department)  # Инициализация Manager с нужными аргументами
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\EvoTechPC\Desktop\учеба\ввит\lab7\Main.py", line 11, in __init__
    super().__init__(name, id)
TypeError: Technician.__init__() missing 1 required positional argument: 'specialization'

Task is:

  1. Create an Employee class with common attributes like name (name), id (identification number), and methods like get_info() that return basic information about the employee.

  2. Create a Manager class with traditional attributes like department (department) and methods like Manage_project() that symbolize managing projects.

  3. Create a Technician class with respect to attributes like specialization (specialization) and methods like Perform_maintenance() that mean performing maintenance.

  4. Create a TechManager class that becomes a manager as well as a technician. This class should combine management skills and technical skills, for example having methods for managing projects and performing maintenance.

  5. Add an add_employee() method that allows the TechManager administrator to list subordinates.

  6. Implement the get_team_info() method that displays information about all subordinate employees.

If anyone can help me, I would be very grateful

Upvotes: 0

Views: 51

Answers (0)

Related Questions