ubject: Object oriented programming (OOP): DO TASK IN C++ Define a pure abstract base class called BasicShape . The BasicShape class should have the following members:   Private Member Variable: area, type double used to hold the shape's area. Public Member Functions:             setArea: assigns received argument to area variable.            getArea. This function should return the value in the member variable area. calcArea. This function should be a pure virtual function.   Next, define a class named Circle . It should be derived from the BasicShape class. It should have the following members: Private Member Variables: centerX, type integer used to hold the x coordinate of the circle’s center. centerY, type integer used to hold the y coordinate of the circle’s center. radius, type double used to hold the circle's radius. Public Member Functions: constructor—accepts values for centerX, centerY, and radius. Should also call the overridden calcArea function described below. getCenterX—returns the value in centerX. getCenterY—returns the value in centerY. calcArea—calculates the area of the circle (area = 3.14159 * radius * radius) and stores the result in the inherited member variable area in base class.   Next, define a class named Rectangle. It should be derived from the BasicShape class. It should have the following members: Private Member Variables: width, type double  used to hold the width of the rectangle. length, type double  used to hold the length of the rectangle. Public Member Functions: constructor—accepts values for width and length. Should also call the overridden calcArea function described below. getWidth—returns the value in width. getLength—returns the value in length. calcArea—calculates the area of the rectangle (area = length * width) and stores the result in the inherited member variable area in base class.   Write a main function that will declare pointer array of type BasicShape having size 4 and initialize the array with the objects of type circle, circle, rectangle and rectangle respectively. Then using for loop, display the area of those shapes (circle and rectangle) whose area > 100 .   Note: Do not change the names of functions and variables. Otherwise, marks will be deducted. Do not define extra functions.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 1PE: In Chapter 10, the class clockType was designed to implement the time of day in a program. Certain...
icon
Related questions
Question
100%

subject: Object oriented programming (OOP):

DO TASK IN C++

Define a pure abstract base class called BasicShape . The BasicShape class should have the following members:

 

Private Member Variable:

area, type double used to hold the shape's area.

Public Member Functions:

            setArea: assigns received argument to area variable.           

getArea. This function should return the value in the member variable area.

calcArea. This function should be a pure virtual function.

 

Next, define a class named Circle . It should be derived from the BasicShape class. It should have the following members:

Private Member Variables:

centerX, type integer used to hold the x coordinate of the circle’s center.

centerY, type integer used to hold the y coordinate of the circle’s center.

radius, type double used to hold the circle's radius.

Public Member Functions:

constructor—accepts values for centerX, centerY, and radius. Should also call the overridden calcArea function described below.

getCenterX—returns the value in centerX.

getCenterY—returns the value in centerY.

calcArea—calculates the area of the circle (area = 3.14159 * radius * radius) and stores the result in the inherited member variable area in base class.

 

Next, define a class named Rectangle. It should be derived from the BasicShape class. It should have the following members:

Private Member Variables:

width, type double  used to hold the width of the rectangle.

length, type double  used to hold the length of the rectangle.

Public Member Functions:

constructor—accepts values for width and length. Should also call the overridden calcArea function described below.

getWidth—returns the value in width.

getLength—returns the value in length.

calcArea—calculates the area of the rectangle (area = length * width) and stores the result in the inherited member variable area in base class.

 

Write a main function that will declare pointer array of type BasicShape having size 4 and initialize the array with the objects of type circle, circle, rectangle and rectangle respectively. Then using for loop, display the area of those shapes (circle and rectangle) whose area > 100 .

 

Note: Do not change the names of functions and variables. Otherwise, marks will be deducted. Do not define extra functions.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,