Write a class that has three overloaded static methods for calculating the areas of the following geometric shapes:
Here are the formulas for calculating the area of the shapes:
|Area of a circle||Area = nr^2 where: n is Math.PI and r is the circle's radius|
|Area of a rectangle||Area = Width x Length|
|Area of a cylinder||Area = nr^2h where: n is Math.PI, r is the radius of the cylinder's base, and h is the cylinder's height|
Because the three methods are to be overloaded, they should each have the same name, but different parameter lists. Demonstrate the class in a complete program.
Breaking it down
- Write three unit tests for each
getArea overloaded method validating the logic in the method is correct.