[SOLVED] CS150 Lab 24

35.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (1 vote)

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).

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.