Consider the following classes: public abstract class Cat { private int age; private double weight; private double top_speed; public void run(double newSpeed) { ... } private void eat(double portionSize) { ... } // ... -> getXXX() and setXXX() methods here } } public class Cheetah extends Cat { private String type; public Cheetah(int age, double wt, double sp, String type) { this.type = type; setAge(age); setWeight(wt); setTopSpeed(sp); } private void run(double newSpeed) { ... } public void camouflage() { ... } // ... -> // getXXX() // and setXXX() methods
Consider the following classes:
public abstract class Cat {
private int age; private double weight; private double top_speed;
public void run(double newSpeed) { ... }
private void eat(double portionSize) { ... }
// ... -> getXXX() and setXXX() methods here }
} public class Cheetah extends Cat {
private String type;
public Cheetah(int age, double wt, double sp, String type) { this.type = type; setAge(age); setWeight(wt); setTopSpeed(sp);
} private void run(double newSpeed) { ... }
public void camouflage() { ... } // ... ->
// getXXX()
// and setXXX() methods here }
}
Which design principles are violated by these classes? Explain it and then correct it
Trending now
This is a popular solution!
Step by step
Solved in 2 steps