In: Other
Must be done with the Program Raptor
Program #2 - Area of Shapes
Design a superclass called Shape that contains two functions—getVolume() and getInput(). The getVolume and getInput functions in the Shape class will simply return 0, you will derive from them in your subclasses mentioned below. Define 3 subclasses of the Shape class—Sphere, Cube, and Cone. The sphere class will need a radius field, the cube class will need a length field, and the cone class will need radius and height fields. Declare all of the appropriate setters and getters for each of these classes. The sphere class will calculate it’s volume as 4/3 * PI * r * r * r. The cube’s volume is length * length * length. The cone’s volume is PI * radius * radius * height/3. Override the getInput method for each subclass so it will prompt the user to input the dimensions for each shape. Then, override the getVolume method in each subclass so it will calculate and return the volume of the shape.
Demonstrate your classes be writing a menu driven program that allows the user to select which shape they want to create. After making their selection, the program will call getInput on the object to ask the user to input the appropriate dimensions for that shape. The program should then display the volume for that shape. The menu will continue to display until the user chooses to quit.
Example Output:
Please select an option:
1) Volume of a sphere
2) Volume of a cube
3) Volume of a cone
4) Quit
Enter your selection:
2 [Enter]
Enter the cube length:
10 [Enter]
The Volume for your cube is 1000
Please select an option:
1) Volume of a circle
2) Volume of a rectangle
3) Volume of a triangle
4) Quit
Enter your selection:
4 [Enter]
Thanks for playing!
Steps to create the Raptor Program
Step 1) Create all the UMLs according to the diagram below.
Step 2) Create the flowchart for each method of the class Shape as below.
a) Create the flow chart for getVolume() method as below.
b) Create the flowchart for getInput() method as below.
Step 3) Create the flowchart for the sub class Sphere for each methods as below.
a) getInput() method
b) getRadius() method
c) getVolume() method
d) setRadius() method
Step 4) Create the class flowchart for the subclass Cube as given below.
a) getLength() method
b) getVolume() method
c) getInput() method
d) setLength() method
Step 5) Create the flowchart for the methods of the class Cone as given below.
a) getVolume() method
b) getInput() method
c) getRadius() method
d) setRadius() method
e) getHeight() method
f) setHeight() method
Step 6) Create the flowchart for the main() method as given below.
-------------------------------------------------------------------------------------------------------------------------------------
OUTPUT
=============================== XXXXXXXX
=================================