Question: Done in Java. Any help is appreciated! We have review a java class Rectangle that defines a rectangle by its top left corner and height/width

Done in Java. Any help is appreciated!

Done in Java. Any help is appreciated! We have review a java

We have review a java class Rectangle that defines a rectangle by its top left corner and height/width values. Implement a subclass Square by extending the Rectangle class such that a square is defined by its center position and the side length. In the constructor, accept the x- and y-positions of the center and the side_length of the square and use constructor chaining when creating your square. Also use methods from Rectangle class whenever available and keep your own code in square class to the minimum. You may want to look up these methods in the documentation for the Rectangle class. Do not write any new method in Square class with functionality that is provided by Rectangle class. Also supply two other methods getArea() and getPerimeter() which compute and return the area and perimeter of the square respectively. Write a sample program that creates an ArrayList of 5 squares with different center points and different side lengths. Prints all squares (i.e., center points and side lengths, their areas, and perimeters) using the toString method {be sure to override the toString method to print the ArrayList or each Square object from the list in a proper format}

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!