Creating abstract classes with Java
Introduction to abstract classes, you learned some of the fundamentals of abstract classes and saw why they are necessary in Java. Now, keep this in mind as you put what you’ve learned into practice!
In this lab, you’ll help Toni program two robots, SideKick and WatADriver, to function as required. Toni has a tendency to repeat code across programs. To help him, you’ll create a superclass to consolidate common properties and methods shared by SideKick and WatADriver. This class will be made abstract to prevent its object from being created, ensuring it only serves to provide shared functionality. SideKick and WatADriver will inherit the class’ properties and implement any abstract methods defined in it. This way, you’ll promote code reuse and enforce the implementation of essential functionalities.
Help Toni use abstract and child classes in a Java program to promote code reuse and enforce functionality. This involves creating a superclass Robot to consolidate common properties and methods for two robots, SideKick and WatADriver. The superclass must be made abstract to prevent objects from being created in the class Robot since the Robot class has no functionality other than to contain common code. You must ensure that SideKick and WatADriver inherit from this abstract class and implement any abstract methods defined within the Robot class.
This practice will move common code to the abstract class, add child classes, and ensure proper implementation of essential functionalities.