Given the following class declarations of Rectangle, Triangle, andPyramid, write
ID: 3610667 • Letter: G
Question
Given the following class declarations of Rectangle, Triangle, andPyramid, write the member function Pyramid::getArea () that returnsthe surface area of the pyramid. Use Triangle::getArea () andRectangle::getArea () as well.class Triangle
{
private:
float base, height;
public:
//Constructors
Triangle (): base (0), height (0) {}
Triangle (float b, float h): base (b), height (h) {}
Triangle (const Rectangle &other);
//Accessors
float getBase () const;
float getHeight () const;
float getArea () const;
//Mutators
void setBase (float);
void setHeight (float);
};
class Pyramid
{
private:
Rectangle floor;
Triangle faceA;
Triangle faceB;
public:
//Constructors
Pyramid () {}
Pyramid (Rectangle f, Triangle a, Triangle b): floor (f), faceA(a), faceB (b) {}
Pyramid (const Pyramid &other);
//Accessors
Rectangle getFloor () const;
Triangle getFaceA () const;
Triangle getFaceB () const;
float getArea () const;
//Mutators
void setFloor (Rectangle);
void setFaceA (Triangle);
void setFaceB (Triangle);
};
class Rectangle
{
private:
float length, width;
public:
//Constructors
Rectangle (): length (0), width (0) {}
Rectangle (float l, float w): length (l), width (w) {}
Rectangle (const Rectangle &other);
//Accessors
float getLength () const;
float getWidth () const;
float getArea () const;
//Mutators
void setLength (float);
void setWidth (float);
};
If anyone can please help, it would be muchappreciated! thanks !
Explanation / Answer
x.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.