SOLID Violation

You have a Shape class with a draw() method and an if-else chain that checks the shape type (circle, rectangle, triangle) to decide how to draw it. Adding a new shape requires modifying this method. Which principle is violated, and what is the standard fix?

A

Interface Segregation Principle: fix by splitting draw() into separate interfaces per shape type

B

Liskov Substitution Principle: fix by ensuring all shapes are substitutable for the base Shape

C

Open-Closed Principle: fix by making Shape an interface with a virtual draw() method, so new shapes extend the system without modifying existing code

D

Dependency Inversion Principle: fix by making the drawing code depend on an abstraction rather than concrete shapes