Reputation: 1
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:
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.
Create a Manager
class with traditional attributes like department
(department) and methods like Manage_project()
that symbolize managing projects.
Create a Technician
class with respect to attributes like specialization
(specialization) and methods like Perform_maintenance()
that mean performing maintenance.
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.
Add an add_employee()
method that allows the TechManager
administrator to list subordinates.
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