Starting from:

$29.99

CS150 Lab 24 Solution

Modify Lab 23 to split it into 3 files, main.cpp, circle.cpp and circle.h. circle.h must have include guards. The program should still do the same thing it does in Lab 23.
Lab 23:
Modify Lab 22 so that the radius variable in class circle is private. Write a setter and getter function for radius, as well as a default constructor that initializes it to 0 and a constructor that takes one parameter for radius. If radius is given as a negative in a call to the setter or the constructor set it to 0 instead.
Lab 22:
Create a program that defines a class called circle. Circle should have a member variable called radius that is used to store the radius of the circle. Circle should also have a member function called calcArea that calculates the area of the circle using the formula area = pi*r^2. Area should NOT be stored in a member variable of circle to avoid stale data.
Use a global constant for PI and set it to 3.14159.
In main, instantiate (declare/create) and use circle objects as needed to prove that all of your functions, including both constructors, work properly (construct a test case for your class in main).

More products