SOLID Principles Practice Questions
SOLID Principles Practice Questions
Ensure that the program is easy to extend if new features are added, such as tracking book
borrowing.
2. Payment Gateway
Design a system for processing payments. The program should:
- Support Credit Card and PayPal payment methods.
- Allow new payment methods (e.g., Google Pay) to be added without modifying existing
code.
3. Shape Drawing
Create a program for a drawing tool. The tool should support drawing shapes like circles,
rectangles, and triangles.
- Each shape should have methods to calculate its area and perimeter.
- Add support for new shapes without changing the existing classes.
4. Vehicle Management
Implement a class hierarchy for vehicles.
- The base class should represent a generic vehicle with attributes like speed and fuel.
- Derived classes should include `Car`, `Bicycle`, and `ElectricCar`.
- Extend the system to add new vehicle types like `Truck` or `Motorcycle` without breaking
the existing code.
5. Printer System
Create an interface for a printer that supports the following operations:
- Printing documents.
- Scanning documents.
- Sending faxes.
7. E-Commerce System
Build a program for an e-commerce platform to manage products and orders. The program
should:
- Allow customers to browse products and add them to a cart.
- Handle discounts for different product categories.
- Process payments through multiple payment gateways.
8. Employee Management
Design a system for managing employees in an organization.
- Employees can be full-time, part-time, or freelancers.
- Each type of employee has different ways of calculating salaries.
- Ensure that the program is easy to extend when new employee types are added.