Answered step by step
Verified Expert Solution
Question
1 Approved Answer
[Use C# (c sharp programming) Visual Studio] Write parent class with the name BasicShape. The BasicShape class have Protected Member Variable: area, a double used
[Use C# (c sharp programming) Visual Studio] Write parent class with the name BasicShape. The BasicShape class have Protected Member Variable: area, a double used to hold the shape's area. Public Member Functions: getArea the Accessor. This function should return the value in the member variable area. Parameterized constructor-Initializes area member. Defualt constructor Empty body calcArea. This function should be a incomplete function. Next, define a class named Circle. It should be child of 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-Initializes values for centerX, centery, and radius.getCenterXreturns the value in centerX. getCenterY-returns the value in centerY. The overridden calcArea function in Circle described below. 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 Child 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. getWidth-returns the value in width.getLength-returns the value in length. The overridden calcArea function in Rectangle described below.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, make a driver program that defines a Circle object and a Rectangle object. Demonstrate that each object properly calculates and reports its area. What type of inheritance is used in this given scenario(Single , Multiple or Multilevel). Use pi=3.14159 as double
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