Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please only C++ , NOT C, or C#, or Java Here is the hiarchy to use The output sh

ID: 3566454 • Letter: P

Question

Please only C++, NOT C, or C#, or Java

Here is the hiarchy to use

The output should be as follows:

Please only C++, NOT C, or C#, or Java Implement the Shape hierarchy shown on page 485 of the ter. Create two dynamic arrays of base class pointers where the objects are ordered as shown in the exe output for each array. All work done with the objects should be through base class pointers only. Implement the triangle as an equilateral triangle and the tetrahedron as a regular tetrahedron. Wilcipedia.org can help you get the correct formulas for the shapes. Your Shape class should have 2 instance variables for the coordinates of the shape?s center. Circle and Sphere objects have a radius. Square, Cube, Triangle, and Tetrahedron objects have a side. You should have at least these functions as virtual: print area volume (where applicable) Implement other functions as appropriate for each class. Decide which das ses should be abstract. Consider which classes actually represent things that exist and which represent only design abstractions. In general, design abstractions should be abstract classes, while the classes that represent real things should not be abstract. Here is the beginning of your main function: The output should show all the information for the object. Notice how the display is done. Overload the

Explanation / Answer

#include #include #include using namespace std; class Shp { public: Shp( double = 0.0, double = 0.0 ); // default constructor double getCenterX() const; // return x from coordinate pair double getCenterY() const; // return y from coordinate pair virtual void print() const = 0; // output Shp object protected: double xCenter; // x part of coordinate pair double yCenter; // y part of coordinate pair }; // end class Shp class TwoDimensionalShp : public Shp { public: // default constructor TwoDimensionalShp( double x, double y ) : Shp( x, y ) { } virtual double getArea() const = 0; // area of TwoDimensionalShape }; // end class TwoDimensionalShp class Square : public TwoDimensionalShp{ public: Square(int Length): TwoDimensionalShp(Length,Length){} virtual ~Square(){} virtual double getArea()const=0; protected: int Length; }; class Circle : public TwoDimensionalShp{ public: Circle(int radius): TwoDimensionalShp(radius,radius){} virtual ~Circle(){} virtual double getArea()const=0; protected: int radius; }; class Triangle : public TwoDimensionalShp{ public: Triangle(int base,int height): TwoDimensionalShp(base,height){} virtual ~Triangle(){} virtual double getArea()const=0; protected: int base; int height; }; int main(){ vector shps(3); shps[0]= new Square(4); shps[1]= new Circle(3); shps[2]= new Triangle(2,4); return 0; } double Square::getArea() const { return Length*Length; } double Circle::getArea() const { return 3.14 * radius*radius; } double Triangle::getArea() const { return (base * height)/2; } void Shape::print() const { cout