You should design classes for three different shapes (triangle, square, and circle) with the specifi-
cations listed below. These classes are to be used by the main program (the class with the "main"
method), and passed to the Canvas class for drawing. Thus, they must use standard class names
and method names in order to work correctly. We will leave class attributes up to you, looking at
the values that can be set is a good place to start.
The TAs will be using automated tests to grade your submissions so make sure to use
the given method signatures i.e. the function names, order of the input parameters
and the output type should match the ones given.
Note: In java, both integer and floating point division are performed using the / operator.
Integer division floors the result of the division-for example, 1/2 will produce 0, rather than
the (expected) 0.5. Make sure that if you use any division in your methods for the shape
classes, at least one of the operands is of type double. For example, 1.0/2, 1/2.0, and
1.0/2.0 will all produce 0.5.
Note: In order to use Color in this project, you will need to import java.awt.Color at the
top of each shape class.
2.1 Circle Class Methods
• Constructor
Input: x position (double), y position (double), radius (double)
calculatePerimeter
Input: none
Output: perimeter of the circle (type double)
calculateArea
Input: none
Output: area of the circle (type double)
• set Color
Input: color of the shape (type Color)
Output: none (void)
set Pos
Input: x, y position of the center (both doubles)
Fig: 1