Class: Square Create a class called "Square", which is inherited from “TwoDimensionShape” class. The "Square" class is used to calculate the Area and the Perimeter of square shapes...


Class: Square
Create a class called "Square", which is inherited from
“TwoDimensionShape” class. The "Square" class is used to calculate the
Area and the Perimeter of square shapes when their side-length is given, or in contrast,
finding the side-length of the square when the Area or the Perimeter of the square is given.
The specifications of this class are below.
 Data Members (Attributes): All are private.
 sideLength: the sidelight (L) of the square.
 Methods/Operations/Getters/Setters:
 Default Constructor: when creating an object this constructor must set the side-
length of the square by calling the method setSideLength(). Also, this constructor will
call the findArea() and the findPerimeter() in addition to summaryPrint() to calculate
and print all needed information.
 User-Defined Constructor: when creating an object this constructor should
find the side-length of the square by calling the method findSquareSideLength()
and pass the Area or the Perimeter of the square to it. Finally, this constructor
should call the summaryPrint() method to print all information on the screen
 Method setSideLength(): to set the side-length (L) of the square, by the keyboard.
Entered values must be validated, otherwise, repetition occurs (must be re-entered
again).
 Method getSideLength(): to get the side-length (L) of the square.
 Method findArea(): must override the abstract method, findArea(), to calculate the
square’s area.
 Method findPerimeter(): must override the abstract method, findPerimeter(), to
calculate the square’s perimeter.
 Method findSquareSideLength(): is used to calculate the side-length of the square by
given the Area or the Perimeter value through the user-defined constructor.
 Method summaryPrint(): must override the abstract method, summaryPrint(), to print
all information on the screen.

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here