1. Design a class called Circle. The circle is defined by its center (x,y) and radius r. Here is the UML for the class: Circle -int x //x coord of the center -int y // y coord of the center -int radius + Circle() //default constructor that sets origin to (0,0) and radius to 1 +Circle(int x, int y, int radius) // regular constructor +getX(): int +getY(): int +getRadius(): int +setX(int newX: void +setY(int newY): void +setRadius(int newRadius):void +getArea(): double // returns the area using formula pi*r^2 +getCircumference // returns the circumference using the formula 2*pi*r +toString(): String // return the circle as a string in the form (x,y) : radius 2. make a specification file called CircleHeader.h which contains the class specification with member variable (attribute) declarations and function (aka instance method) headers 3. make a file called Circle.cpp which implements the Circle class as given in the UML diagram above. This file will implement instance methods (behaviors/functions that initialize, access and process data). These function names will be prefixed with the class name followed by the scope resolution operator :: to indicate which class they are declared in 4. make a driver class called CircleMain.cpp to do the following: a. Declare and instantiate a circle called circleOne using the default constructor b. Declare and instantiate a circle called circleTwo with center at origin and radius =4. c. Display the circles in the format (x,y):radius using getter methods for getting x, y and radius d. Declare and instantiate a circle called circleThree with at (-2,-9) and radius =6 e. Display circleThree in the format (x,y):radius using the toString method f. Display the areas and circumferences of all the circles g. Include math.h and use M_PI for PI in calculations 5. Make sure your program has good documentation and correct programming style 6. Your program needs to follow top down design
M02 C++
1. Design a class called Circle. The circle is defined by its center (x,y) and radius r.
Here is the UML for the class:
Circle
-int x //x coord of the center
-int y // y coord of the center
-int radius
+ Circle() //default constructor that sets origin to (0,0) and radius to 1
+Circle(int x, int y, int radius) // regular constructor
+getX(): int
+getY(): int
+getRadius(): int
+setX(int newX: void
+setY(int newY): void
+setRadius(int newRadius):void
+getArea(): double // returns the area using formula pi*r^2
+getCircumference // returns the circumference using the formula 2*pi*r
+toString(): String // return the circle as a string in the form (x,y) : radius
2. make a specification file called CircleHeader.h which contains the class specification
with member variable (attribute) declarations and function (aka instance method)
headers
3. make a file called Circle.cpp which implements the Circle class as given in the UML
diagram above. This file will implement instance methods (behaviors/functions that
initialize, access and process data). These function names will be prefixed with the class
name followed by the scope resolution operator :: to indicate which class they are
declared in
4. make a driver class called CircleMain.cpp to do the following:
a. Declare and instantiate a circle called circleOne using the default constructor
b. Declare and instantiate a circle called circleTwo with center at origin and radius
=4.
c. Display the circles in the format (x,y):radius using getter methods for getting x, y
and radius
d. Declare and instantiate a circle called circleThree with at (-2,-9) and radius =6
e. Display circleThree in the format (x,y):radius using the toString method
f. Display the areas and circumferences of all the circles
g. Include math.h and use M_PI for PI in calculations
5. Make sure your program has good documentation and correct
6. Your program needs to follow top down design
Step by step
Solved in 5 steps with 1 images