Question: Please answer these problems, thank you! Exercise 1 - Creating the super class (3 points) Step 1: Create a Boat class that contains information and

 Please answer these problems, thank you! Exercise 1 - Creating thesuper class (3 points) Step 1: Create a Boat class that containsinformation and methods common to all boats. t will be used asa super class in subsequent tasks. It has the attributes and methods

Please answer these problems, thank you!

Exercise 1 - Creating the super class (3 points) Step 1: Create a Boat class that contains information and methods common to all boats. t will be used as a super class in subsequent tasks. It has the attributes and methods shown in the table below. Note carefully, that the parameterized constructor, does not make direct assignments to instance variables (attributes). Rather, it must initialize them using the appropriate mutators Attributes color length Method Boat Boat Data type A String value for the boat color An int value for the boat length Description Default constructor that initializes color to white and length to 20 A constructor with 2 parameters; a string value for the boat color that initializes color using setcolor and an integer value for the boat length that initializes 1ength using setLength A mutator that tests the input parameter to insure it is white, red, blue or yellow. If so, it sets color and returns true. For all other values, c?1 r is not set and a false is returned An accessor that returns the color A mutator that tests the input parameter to ensure it is in the range of 20 to 50 inclusive. If so, it sets length and returns true. For all other values, length is not set and a false is returned An accessor that returns the length Returns a string using String.format: colorcolor Length length setColor getcolor setLength getLength tostring Although not strictly necessary, writing a TestBoat test class to verify the design of Boat is recommended. Note in the sample output below, each mutator was tested with both good and bad data Lab 11 Inheritance-bash-107x23 Janeway: Lab11 Inheritance jim$ java TestBoat Testing superclass Boat: Color blueLength 25 Setting Boat's length to 100. Error: Boats can only be between 20 and 50 feet, inclusively. Setting Boat's color to "purple" Error: Boats can only be white, red, blue and yellow. Janeway: Lab11 Inheritance jim$

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