Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 . Create a base class called Shape. a . All Shapes have a shapeType i . e . Square , Pentagon , Heptagon ,
Create a base class called Shape.
a All Shapes have a shapeType ieSquarePentagonHeptagon
Decagon a shapeName user defined a numberSides and a
sideLength which is generated as a random number..
The number of sides for each type are:
i Square
ii Pentagon
iii. Heptagon
iv Decagon
b Provides a constructor that allows the shapeName and sideLength to be
set by the client when the object is created. This constructor should also
output the message Invoking Shape argument constructor.
c Provides a destructor for this class that outputs the message Invoking
Shape destructor. This destructor is virtual, which means that this
destructor will file, and the destructor from the inherited class will fire.
d Provides a function called calcPerimeter that will calculate and return
the Perimeter. The formula is numberSides sideLength.
e Provides a function called displayShapeInfo that cannot be
implemented. That is it should be declared as a purely virtual function.
f Provides Get and Set methods to allow the shapeName, shapeType,
numberSides, and sideLength to be accessed. Note: The setter for
shapeType and numberSides must be located in the private section of
the h file. This is because these data members are Read Only as far as the
world outside the class is concerned. Only the class or the class that
inherits from this class will be able to access the setter when the setter is in
the private section.
From the Shape class, derive the Square, Pentagon, Heptagon, and Decagon
classes.
a The derived classes should each have a constructor and destructor that
output an appropriate message eg the Square constructor outputs
Invoking Square argument constructor, and the Square destructor
outputs Invoking Square destructor etc.
b The constructor of each derived class should allow the shapeName and
sideLength of the Shape to be passed directly to the constructor of the
base class. The derived constructor body will then use the base class
private setters to pass in the hardcoded shape type and number of sides
using the setShapeName and setNumberSides setters.
Example: The example below shows parameters received by the derived
CSIS Lab
Page of
class constructor and those parameters being passed to the base class
constructor.
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