Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In c++ Task: Write a program that defines a class Circle and implement it as required. The class Circle should consist of three private member

In c++ Task: Write a program that defines a class Circle and implement it as required. The class Circle should consist of three private member variables: radius of type double, Pi of type double and color of type string. Circle should also include the following member functions: print to output the area and diameter of the circle. setPi to set Pi to the value of 3.14159. setRadius to set the radius according to the parameters. setColor to set the color according to the parameter. getPi to return Pi. getRadius to return the radius. getColor to return the color. area to return the area of the circle. area = pi* radius * radius. getCircumference to return circumference of the circle. circumference = 2 * pi * radius A default constructor to initialize radius 1 pi to 3.14.159 and color to white. A constructor that initializes radius, Pi and color according to the parameters.

Using the class Circle to implement the basic properties of a circle. Every cylinder has a base and height, where the base is a circle. The class cylinderType will have the follow new attribute double height. Define a class cylinderType that can capture the properties of a cylinder and perform the usual operation on the cylinder. Derive this class from the class circleType (using circle) Some of the operations to be performed on a cylinder are Calculate and print the volume Calculate and print the surface area Set the height print to print the radius, height, surface area and volume. setHeight to set the height according to the parameters. getHeight to return the height. CalcArea to calculate the area (2 * Pi * radius2 + height) CalcVolume to calculate the volume ( Pi * radius2 * height) A default constructor An overload constructor that initializes according to the parameters. equalVolume to compare two Cylinder objects volume. Return true if they are the same, otherwise, return false. In the function main, you should write statements to test your class implementations.

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_2

Step: 3

blur-text-image_3

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

Principles Of Multimedia Database Systems

Authors: V.S. Subrahmanian

1st Edition

1558604669, 978-1558604667

More Books

Students also viewed these Databases questions