Question: Define a base class named Robot, used to define the capabilities of various types of robots. Derive classes Drone, Vacuum, and MovieRobot each of which

Define a base class named Robot, used to define the capabilities of various types of robots.
Derive classes Drone, Vacuum, and MovieRobot each of which describe a specific type of robot, and which redefine certain Robot behaviors appropriately.
Derive more specific MovieRobot classes called HAL9000, Replicant, and TeeOneThousand which each have different capabilities.
Prepare the assignment for submission and submit it
Rules:
This exercise may be completed in groups.
You may not import any extra functionality besides the default. For example, System and Math are imported by default and thus may be used, whereas something like ArrayList must be explicitly imported so it is disallowed.
The main method in any class will not be tested; you may use it any way you want.
Comment your code using the Javadoc style. Since most methods are fairly short, focus on documenting the classes and their relationships.
You may add additional fields (but not methods) as long as they are private (not public, protected or default).
Use proper encapsulation.
Robot Class
The term "robot" (at least in popular usage) can refer to a very broad category of things, and yet there is a common image that we often have in mind when discussing robots in general: machines that interact with the world. Usually, we categorize different types of robots based on their capabilities. Let's create a general class that identifies some common capabilities that different robots might have, with the possibility that new capabilities might be added in the future. The Robot class we are about to write will be a general class which we can use to describe any type of robot - we won't worry about the specifics yet, and instead we'll use subclasses to describe those.
Our Robot class will include the following:
A public constructor, with the parameters int serialNumber, boolean flies, boolean autonomous, boolean teleoperated. The serialNumber is a number which uniquely identifies the robot, while the remaining parameters all represent different capabilities a robot can have: if flies is true, the robot can move through the air, autonomous is true when the robot can act on its own without a human operator, and teleoperated indicates whether a human can operate the robot manually.
A void method with public access called setCapabilities for setting the capabilities after object creation with the parameter list boolean flies, boolean autonomous, boolean teleoperated.
A public getter called getSerialNumber for the serialNumber. We do not need a setter because we do not expect to change the serial number after it is set (it may even make sense to declare the method and the corresponding field final).
Public methods canFly, isAutonomous, and isTeleoperated, each of which take no parameters and return boolean. These method indicate which capabilities the robot supports. They may be redefined in subclasses, but for now, each of these methods should return whatever the capabilities were set to.
A public getCapabilities method that takes no parameters and which returns a String containing each of the capabilities of the robot separated by spaces. For example, if canFly returns true, isAutonomous returns false, and isTeleoperated returns true, then getCapabilities should return the string "canFly isTeleoperated" (order and case are important). If all three returned true the string should be "canFly isAutonomous isTeleoperated". If none of them return true, the empty string should be returned (""). NOTE: in order for this method to work correctly for subclasses, you should use the previously defined canFly, isAutonomous, and isTeleoperated methods rather than access any data members directly.
An overridden toString method which returns a String in the format "ID: , Capabilities: "(replacing with actual serial number and list of capabilities).
Drone Class
Our simplest type of robot will represent a drone. Even though many different types of drones exist, they all have the same basic functionality, at least for the purposes of this project. All drones can fly, are teleoperated and not autonomous. To implement this subclass, we need to define the following:
Extend the Robot class.
A public constructor with just a single parameter: int serialNumber. Hint: you will need to explicitly invoke the superclass constructor with the correct arguments.
An overridden canFly method which always returns true.
An overridden isAutonomous method which always returns false.
An overridden isTeleoperated method which always returns true.
NOTE: this class does not define or override the getCapabilities method, but it is still inherited by this subclass, and it should still give the correct output when on instances of this subclass. If you've followed the note above, this will be the case.
Vacuum Class
Our next type of robot is the humble vacuum, a consumer product which autonomously vacuums your house. All vacuums ha

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 Programming Questions!