1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
// CIS 235 Lab 1 - defining classes , writing member functions
#include <iostream>
#include <cmath>
using namespace::std;
class circle {
public:
void setX( double xV );
void setY( double yV );
void setR( double rV);
void set(double value, char whichOne); // use 'x' for x, use 'y' for y
// and use 'r' for radius
double getX(void) const;
double getY(void) const;
double getR(void) const;
double get(char whichOne) const; // use 'x' for x, use 'y' for y
// and use 'r' for radius
void print(ostream & w) const;
double area(void) const;
void input(void);
circle move( double xC, double yC) const; // return a circle formed from
// the invoking instance by:
// keep the same radius, adjust the x and y
// of the center by the xC and yC amounts
circle reSize(double rC) const; // return a circle formed from
// the invoking instance by:
// keep the same center
// adjust the radius by rC
bool isInside(const circle & inner) const; // return true if the parameter
// circle inner is completely inside
// the invoking instance, return
// false otherwise
private:
double x,
y,
radius;
};
// The following is NOT a member function
circle makeCircle(double xV, double yV, double rV);
void main()
{
circle a;
// test input and print using a
// test the area function using a
// add 2.4 to the x value of the circle a - use print to show the answer
// test makeCircle, move and reSize - use print to show the answers
// using input create a circle named one
// using set create a circle named two that is inside circle one
// using setX, setY, and setR create a circle named three that is not inside one
// test the isInside function
// Use of function chaining
// starting with center of x = 2.3, y = 4.5 and radius = 8.2
// move the circle by adjusting x by 1.1 and y by 3.3
// then resize the circle by adding 5.5 to the radius
// print the resulting circle
return;
}
// PROGRAM OUTPUT
|