#include <iostream> using namespace std; class Circle { int id; int x, y; float radius; bool LocIsValid(int, int); public: Circle(); // constructor decl bool Move(int); bool Move(int, int); int OriginXGet(); int OriginYGet(); void OriginSet(int, int); // method decl void Print(); float RadiusGet(); // method decl void RadiusSet(float); // method decl }; Circle::Circle() { static int sernum=128; // value of sernum is preserved across function calls // all circles begin at origin x = 0; y = 0; // all circles begin with radius 1.1 radius = 1.1; id = sernum++; } bool Circle::LocIsValid(int newX, int newY) { if (newX < 0 || newY < 0) return false; return true; } bool Circle::Move(int xaxis) { x += xaxis; return true; } bool Circle::Move(int xaxisoffset, int yaxisoffset) { x += xaxisoffset; y += yaxisoffset; return true; } void Circle::OriginSet(int newX, int newY) { if (LocIsValid(newX, newY) == false) return; x = newX; y = newY; } int Circle::OriginXGet() { return x; } int Circle::OriginYGet() { return y; } void Circle::Print() { cout << "id: " << id << " origin: (" << x << "," << y << ") radius: " << radius << endl; } float Circle::RadiusGet() { return radius; } void Circle::RadiusSet(float newRadius) // method defn { if (newRadius < 0.5) return; radius = newRadius; } int main() { Circle c1; Circle c2; cout << "Circle c1: "; c1.Print(); cout << "Circle c2: "; c2.Print(); c2.Move(-3); cout << "Circle c2: "; c2.Print(); c1.Move(9, -7); cout << "Circle c1: "; c1.Print(); return 0; }