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
Get step-by-step solutions from verified subject matter experts
