Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . Create a base class called Shape. a . All Shapes have a shapeType i . e . Square , Pentagon , Heptagon ,

1. Create a base class called Shape.
a. All Shapes have a shapeType i.e.Square,Pentagon,Heptagon,
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 4
ii. Pentagon 5
iii. Heptagon 7
iv. Decagon 10.
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 2-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.
2. 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 (e.g., the Square constructor outputs
Invoking Square 2-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 hard-coded shape type and number of sides
using the setShapeName() and setNumberSides() setters.
Example: The example below shows 2 parameters received by the derived
CSIS 112 Lab 8
Page 5 of 2
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

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

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions