Question
Write an inheritance hierarchy of three-dimensional shapes. First, you should create an abstract class that represents all ThreeDimensionalShapes and has methods for finding the volume
Write an inheritance hierarchy of three-dimensional shapes. First, you should create an abstract class that represents all ThreeDimensionalShapes and has methods for finding the volume and surface area of the shapes. Then, you should create three subclasses that inherit from the original class : Sphere, Cube, and Tetrahedron. Each class should have an instance variable representing the dimensions of the shape (for example, the Sphere class should have an instance variable representing its radius), and each class should properly implement the methods to find surface area and volume. (Assume the Tetrahedron class represents a regular Tetrahedron.) Test your classes in a program that asks the user which shape they'd like to create, and what dimensions they'd like to give it. The program should print the surface area and volume of the shape (rounded to two decimal places) before terminating.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started