//MovingObject.cxx //Brooke Loftus #include "MovingObject.h" //provides definitions #include #include"cdraw.h" MovingObject::MovingObject() //simple constructor { x=0; y=0; color=CDraw::randomColor(); } void MovingObject::initialize(int _x, int _y) //initializes values { x=_x; y=_y; color=CDraw::randomColor(); } void MovingObject::setRandColor() { color=CDraw::randomColor(); } int MovingObject::getX(){ return x;} int MovingObject::getY(){ return y;} void MovingObject::throwObject(int dx, int dy) { if( (-1000x) ) x+=dx; if( (-1000y) ) y+=dy; } ostream& operator << ( ostream& out, const MovingObject& mo ) { const int DIAMETER = 50; CDraw::setColor(mo.color); CDraw::fillCircle (mo.x, mo.y, DIAMETER); CDraw::setColor( CDraw::randomColor() ); CDraw::drawCircle (mo.x, mo.y, DIAMETER); return out; } bool operator != (const MovingObject &mo1,const MovingObject &mo2) { bool returned=false; if( (mo1.x==mo2.x)&&(mo1.y==mo2.y) ) return returned; returned = true; return returned; }