Question: Inspect the following three classes. Keeping good OOP practices (such as inheritance, encapsulation, interface segregation, etc,) in mind, remodel them (i.e., Create new classes -from
Inspect the following three classes. Keeping good OOP practices (such as inheritance, encapsulation, interface segregation, etc,) in mind, remodel them (i.e., Create new classes -from these three classes- that follow OOP principles more closely) you can use getters/setters, as well :
public class FamilyCar
{
public String ownerName = "ABC"; public String brand; public int gasTankCapacity; public int mileage; public Int currentSpeed;
public void Accelerate(int speed) { ... } public void Decelerate (int speed) { ... } public void SetRoute (String from, String to) { ... } public void BlowHorn() { ... }
}
...................................................................................................................
public class SportCar
{
public String ownerName = "ABC"; public String brand; public int gasTankCapacity; public int mileage; public int currentSpeed;
public Int turboCapacity ;
public void Accelerate(int speed) { ... } public void Decelerate (int speed) { ... }
public void EngageTurbo { ... } public void SetRoute (String from, String to) { ... } public void BlowHorn() { ... }
}
...........................................................................................................
public class Bike
{
public String ownerName = "ABC"; public String brand; public int currentSpeed;
public void Accelerate(int speed) { ... } public void Decelerate (int speed) { ... } public void SetRoute (String from, String to) { ... } public void RingBell() { ... }
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
