Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 3. HR Matters a) Design and implement in a file p3.py a class hierarchy for employees in a startup company. The base class is
Problem 3. HR Matters a) Design and implement in a file p3.py a class hierarchy for employees in a startup company. The base class is Employee. This has subclasses Manager, Engineer. Class Manager has a subclass called CEO Each employee has these Data attributes: name (string), base salary (float), phone number (string). Make these private attributes (prefix). Constructor taking and saving as attributes name, phone number, and base salary. (Ensure proper call chain for superclass constructors.) .Methods: accessors for the name and the phone number and a method called salary total) that returns the total salary, including any extra benefits that subclasses might have. Amethod (called a mutator) that updates the base salary. Th str method to generate a string representing the object. E.g. "Manager Sophia The repr method to generate the official string representation of the object. An Engineer object does not have anything in addition to what an Employee has. A Manager has in addition to Employee a bonus (Eloat). Its total salary is the base salary+bonus. A CEO has in addition (to a Manager) stock options (loat). Its total salary is the base salary+ bonus - stock options. in the real world stock options are never added to the salary, though) The salary total method must be overridden in subclasses to compute the total salary as described above. It should NOT access the superclass base salary attribute, but it should use the salary total0 method provided by the base class or superclass. b) Write a function print-stafthat takes a sequence (e.g. a list) of employee objects (incl. subclass instances) and prints their name, phone#, and total salary, with one object per line. Write a main method in file p3.py that demonstrates the classes described above. Among other code, create in mai several instances of each class in the employee hierarchy and add them to a list, then call print_staff0 on that list. (i everything works cormectly, this is an illustration of
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started