Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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

Private Member Variable:

area, a double used to hold the shape s area.

Public Member Functions:

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, a long integer used to hold the x coordinate of the circle s center.
centerY, a long integer used to hold the y coordinate of the circle s center.
radius, a double used to hold the circle s radius.

Public Member Functions:

constructor accepts values for centerX, centerY, and radius. Should 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 area.

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

Private Member Variables:

width, a long integer used to hold the width of the rectangle.
length, a long integer used to hold the length of the rectangle.

Public Member Functions:
constructor accepts values for width and length. Should 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 area.

After you have created these classes, create a driver program that defines a Circle object and a Rectangle object. Demonstrate that each object properly calculates and reports its area.

Starter: lab14_ex1_starter.cpp

Submit: lab14_ex1.cpp

lab14_ex1_starter.cpp is

// Chapter 13, Programming Challenge 13: Pure Abstract Base Class Project

// Driver program is used to test the BasicShape (Abstract Base Class), Circle
// (Derived Class) and Rectangle (Derived class).
// The program asks for needed information for both a circle and rectangle and
// returns the area.

#include

using namespace std;

class BasicShape
{

};

class Circle : public BasicShape
{

};

class Rectangle : public BasicShape
{

};

int main()
{
long x, y, length, width;
double rad;

// Demonstrate a Circle.
cout << "Please enter the x coordinate of the circle's center: ";
cin >> x;
cout << "Please enter the y coordinate of the circle's center: ";
cin >> y;
cout << "Please enter the radius of the circle: ";
cin >> rad;
Circle c(x,y,rad);
cout << "The area of the circle is " << c.getArea() << ".";

// Demonstrate a Rectangle.
cout << "nnPlease enter the length of the rectangle: ";
cin >> length;
cout << "Please enter the width of the rectangle: ";
cin >> width;
Rectangle r(width, length);
cout << "The area of the rectangle is " << r.getArea() << ".n";

return 0;
}

 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9681593

Have any Question?


Related Questions in Computer Engineering

Help me define corporate social responsibilityhelp me

Help me define corporate social responsibility. Help me conduct research on a Fortune 500 company and how do you determine just how (or if) the company ranks from a CSR perspective. Help me understand if the findings cha ...

Consider the labor market of the telecom industry is

Consider the labor market of the telecom industry is originally at an equilibrium level E0 and w0. Assume that now the companies offer each employee an iPhone as employment benefit every year. The firms can get iPhone at ...

On a certain banking machine customers arrive at an average

On a certain banking machine customers arrive at an average of 15 per hour. a) What is the probability that 12 customers will use the machine in the next hour? b) What is the probability that there will be fewer than 3 c ...

Let sigmaab give the transition diagram for a

Let Σ={a,b}. Give the transition diagram for a nondeterministic ?nite state machine that accepts the set of strings in {a,b}∗ that contain a substring of length four that begins and ends with the same symbol. For example ...

List and describe the threats posted to information

List and describe the threats posted to information security and common attacks associated with those attacks

A companys balance sheet often reflects its business model

A company's balance sheet often reflects its business model and a horizontal or vertical analysis can help you identify one model from another. Using information from the text, compare horizontal and vertical analysis an ...

Question complete the lab 5-5 programming challenge 1 - yum

Question: Complete the Lab 5-5, "Programming Challenge 1 - Yum Yum Burger Joint," of Starting Out with Programming Logic and Design. Note: You are only required to create the flowchart for this activity; however, notice ...

A firm produces product a and product b this years sales

A firm produces Product A and Product B. This years sales price of Product A have decreased tremendously, and the sale of Product B has increase by 10 percent. The firm has threeemployees that can produce Product A and f ...

Question what are four important tactical tasks for a

Question: What are four important tactical tasks for a negotiator in a distributive situation to consider? Discuss one instance where you have been involved in distributed bargaining. What was the outcome? The response m ...

Systems and networksconsider a node in a packet switched

(Systems and Networks) Consider a node in a packet switched network that has a transmission rate of 100 Mbps. Packets of length 256 bytes arrive at this node. Compute the average queuing delay for 12,000 packets arriving ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As