Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

Whats My Comfort with Change?

Answered: 1 week ago

Question

How to find if any no. is divisble by 4 or not ?

Answered: 1 week ago

Question

Explain the Pascals Law ?

Answered: 1 week ago

Question

What are the objectives of performance appraisal ?

Answered: 1 week ago

Question

4. What advice would you give to Carol Sullivan-Diaz?

Answered: 1 week ago