Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add toString method of the Rectangle class so that it displays the information about the Rectangle object in a user-friendly way (i.e. it informs the

Add toString method of the Rectangle class so that it displays the information about the Rectangle object in a user-friendly way (i.e. it informs the user about the fact that it is a rectangle, and about its dimensions).

Make another class, Square, that is a subclass of Rectangle. The Square constructor should only take one size argument. Think about what can be directly inherited from the Rectangle class and what needs to be overwritten.

Override the toString method from the Rectangle class so that it displays the information about the Square object in a user-friendly way and informs the user about the fact that the object is a square, and about its dimensions.

Make a separate class, SquareTester to test the functionality of the above class. Create a square, print out the information about it using toString method, calculate and display its area and perimeter.

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

Advanced Oracle Solaris 11 System Administration

Authors: Bill Calkins

1st Edition

0133007170, 9780133007176

More Books

Students also viewed these Databases questions