Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 2 . 1 Solids Introduction In this project we will create a class named Solid that will act as an abstract interface class. Classes
Solids Introduction In this project we will create a class named Solid that will act as an abstract interface class. Classes Cuboid, cylinder, and Sphere will inherit from solid and polymorph functions for surface area and volume based on their own individual geometry. Please refer to the UML diagram below for the design: Solid solidType: string SolidsolidType : string getVolume: double gerSurfaceArea : double getType: string A Cuboid width: double length : double height: double Cylinder height: double radius: double PI: const double Sphere radius: double PI: const double Cuboidwdouble, I double, h double getVolume: double getSurfaceArea: double Cylinderh: double, r: double getVolume: double getsurfaceArea: double Spherer: double getVolume: double getsurfaceArea: double Composition is made up of Aggregation contains or more of Inherits from abstract class... Inherits from... Dependency Has a Association Uses a Solid solidType will store text for what kind of solid it is getVolume and getSurfaceArea are pure virtual The constructor initializes solidType getType returns the string for the solid type Cuboid Inherit from Solid Override getVolume and getSurfaceArea to implement these formulas for a cuboid The constructor initializes the parent class with "Cuboid" and length, width and height with the given arguments Cylinder Inherit from Solid Assign to PI Override getVolume and getSurfaceArea to implement these formulas for a cylinder The constructor initializes the parent class with "Cylinder" and height and radius with the given arguments Sphere Inherit from Solid Assign to PI Override getVolume and getSurfaceArea to implement these formulas for a sphere The constructor initializes the parent class with "Sphere" and radius with the given argument main Construct heap pointers to the following objects: o A Cube with A Cube with A Cylinder with A Sphere with Construct a vector of Solid initialized with the four object pointers above. Loop through the vector and output the solid type, volume, and surface area for each object. Sample Output Solid type: Cuboid Volume: Surface Area: Solid type: Cuboid Volume: Surface Area: Solid type: Cylinder Volume: Surface Area: Solid type: Sphere Volume: Surface Area: main.cpp Solids.h Drag file here Solids.cpp Drag file here or Choose on hard drive. Drag file here or Choose on hard drive. or Choose on hard drive.
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