Question: Java You have to solve a geometry-related problem. You are given a bunch of shapes to deal with. These shapes are: Circle, Rectangle and Square.
Java
You have to solve a geometry-related problem. You are given a bunch of shapes to deal with. These shapes are: Circle, Rectangle and Square. The data that you are actually given to represent these shapes are the following:
i. Circle: you have the x- and y-coordinates of the center of the circle and the x- and y-coordinates of another point on the circumference of the circle.
ii. Rectangle: you have the x- and y-coordinates of the bottom left corner of the rectangle and x- and y-coordinates of the top right corner.
iii. Square: you have the x- and y-coordinates of the bottom left corner of the square and the x- and y-coordinates of the bottom right corner.
Your program should be able to represent these different shapes. The main thing that your program needs to do is this: given any shape, it needs to be able to compute the AREA of the shape. What will actually happen is that on a given day, I will give you a particular shape and the details associated with it, and ask you to find its area. On another day, I will give you another shape, and ask you to find its area.
NOTE: Use Math.PI when computing the area of a circle
Test cases:
Test case(s) for circle:
| Circle center x | Circle center y | Circumference points x | Circumference points y | Area |
| 1 | 1 | 2 | 2 | 6.2832 |
| 3 | 5 | 7 | 9 | 100.5312 |
| 0 | 0 | 4 | 3 | 78.54 |
| 2 | 0 | 5 | 0 | 28.2744 |
| 0 | -3 | 0 | 1 | 50.2656 |
| -4 | -3 | -1 | -1 | 40.8408 |
| -1 | -2 | 3 | 1 | 78.54 |
Any others? You should think of some more
Test cases for rectangle:
| Bottom left x | Bottom left y | Top right x | Top right y | Area |
| 0 | 0 | 4 | 3 | 12 |
| 3 | 5 | 7 | 9 | 16 |
| 1 | 10 | 15 | 12 | 28 |
| 2 | 0 | 5 | 0 | ???? |
| -4 | -3 | -1 | -1 | 6 |
| -1 | -2 | 0 | -3 | ???? |
| -1 | -2 | 3 | 1 | 12 |
Note that I did NOT give you the answers to the Area computation of the Rectangle for two of the test cases above. What answer do you get when you actually execute your program for those test cases? Are those answers acceptable for the area of a rectangle? If not, why? And what would you do with data like that? Think about it!! For this lab, you dont have to deal with these test cases in any different way other than to just report the answer your program gave you. But you might receive a future lab/project in which you do have to deal with these test cases. Also, you can think up additional test cases for the Rectangle.
Test cases for Square:
| Bottom left x | Bottom left y | Bottom right x | Bottom right y | Area |
| 1 | 1 | 2 | 1 | 1 |
| 3 | 5 | 7 | 9 | 32 |
| 2 | 0 | 5 | 0 | 9 |
| -4 | -3 | -1 | -1 | 13 |
| -4 | -3 | -1 | -3 | 9 |
| -1 | -2 | 0 | -3 | 2 |
| -1 | -2 | 3 | 1 | 25 |
VERY IMPORTANT: Your code should use inheritance, abstract classes and polymorphism. I want to see only ONE Tester class, and this class should declare an object of only ONE type (class), which is instantiated to different kinds of objects for the three test tables above.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
