Question: You will be refactoring the code from Lab 1 with SOLID and also adding new featuring. Single Responsibility Principle ( SRP ) : Ensure that

You will be refactoring the code from Lab 1 with SOLID and also adding new featuring.
Single Responsibility Principle (SRP):
Ensure that each class has only one reason to change by separating concerns. For instance, if the printInfo() method is doing too much (e.g., formatting and printing), consider refactoring it into a separate class responsible for formatting.
Open/Closed Principle (OCP):
The classes should be open for extension but closed for modification. Implement new functionality, such as calculating annual salary or providing different bonus strategies, by extending existing classes or adding new ones without modifying the existing code.
Liskov Substitution Principle (LSP):
Ensure that objects of a superclass should be replaceable with objects of a subclass without affecting the functionality. For example, if you substitute an Employee object with a Manager object, it should not break the application.
Interface Segregation Principle (ISP):
Refactor the code to use smaller, more specific interfaces rather than one large, general-purpose interface. For example, you might create separate interfaces for Printable, Compensable, etc.
Dependency Inversion Principle (DIP):
Refactor the code so that high-level modules do not depend on low-level modules; both should depend on abstractions (e.g., interfaces). For example, the Manager class should depend on an IBonusStrategy interface rather than a concrete bonus calculation.
New Requirements:
Annual Salary Calculation:
Add a feature that calculates the annual salary for Employee and Manager objects. This should be implemented in a way that adheres to the OCP, allowing for different types of employees (e.g., part-time, full-time) to have different salary calculations.
Bonus Strategy:
Implement different bonus strategies by creating a BonusStrategy interface. For example, a PerformanceBonusStrategy might give a higher bonus based on performance metrics.
Reporting:
Introduce a ReportGenerator class that follows the SRP. This class should be responsible for generating reports (e.g., summary of employee information) rather than having this logic spread across the existing classes.
Interface Refactoring:
Create specific interfaces like Printable, Compensable, etc., to ensure that each class or module only depends on what it needs, adhering to the ISP.
Submission :
Upload your Person.java, Employee.java, Manager.java and then the new files ReportGenerator.java and BonusStrategy.java

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 Programming Questions!