Answered step by step
Verified Expert Solution
Link Copied!

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

12.1 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 + Solid(_solidType : string) getVolume()=0: double + gerSurfaceArea =0: 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 + Cuboid(w.double, 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 1 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 3.14159265359 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 3.14159265359 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 (2,2,2) A Cube with (3,4,5) A Cylinder with (3,2) A Sphere with {4} 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: 8.0000 Surface Area: 24.0000 Solid type: Cuboid Volume: 60.0000 Surface Area: 94.0000 Solid type: Cylinder Volume: 37.6991 Surface Area: 62.8319 Solid type: Sphere Volume: 268.0826 Surface Area: 201.0619 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions