Question: Consider the following class implementations in java. Which OO SOLID design principle is violated ? Explain your answer. Also, how would you change the code

Consider the following class implementations in java. Which OO SOLID design principle is violated ? Explain your answer. Also, how would you change the code to improve the design ? class TransportationDevice { String name; String getName() { ... } void setName(String n) { ... } double speed; double getSpeed() { ... } void setSpeed(double d) { ... } Engine engine; Engine getEngine() { ... } void setEngine(Engine e) { ... } void startEngine() { ... } } class Car extends TransportationDevice { @Override void startEngine() { ... } } class Bicycle extends TransportationDevice { @Override void startEngine() { throw new EngineAbsentException();} }

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!