Question: python 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

python

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. A method (called a mutator) that updates the base salary. The __str__ method to generate a string representing the object. E.g. Manager(Sophia Loren,561-2977777, 100000). 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 (float). Its total salary is the base salary + bonus. A CEO has in addition (to a Manager) stock options (float). 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_total() method provided by the base class or superclass. b) Write a function print_staff() that 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 main() several instances of each class in the employee hierarchy and add them to a list, then call print_staff() on that list. (if everything works correctly, this is an illustration of polymorphism)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!