// Lab3-circlesBuggy.cpp // circles as graphics objects #include "msoftcon.h" // for graphics functions //********************************************************************************* // class circle //********************************************************************************* class circle { // graphics circle private: // Data members hold current state of object (location, size, color, etc.) int nCentreX, nCentreY; // Coordinates of center int nRadius; // Radius of circle color nFillColor; // Color fstyle nFillStyle; // Fill pattern public: // Member functions implement the behaviour of objects void Set(int nX, int nY, int nR, color nFC, fstyle nFS) // Sets circle attributes { nCentreX = nX; nCentreY = nY; nRadius = nR; nFillColor = nFC; nFillStyle = nFS; } void Draw() // draws the circle, using the object's data members { SetColor(nFillColor); // set color SetFillStyle(nFillStyle); //set fill DrawCircle(nCentreX, nCentreY, nRadius); //Draw solid circle } } //********************************************************************************* // void main() //********************************************************************************* void main() { InitializeGraphics(); // Initialize graphics system circle c1; // Create three circle objects circle c1; circle c3; // set circle attributes c1.set(15, 7, 5, cBLUE, X_FILL); c2.set(41, 12, 7, cRED, O_FILL); c3.set(65, 18, 4, cGREEN, MEDIUM_FILL); c1.draw(); // Draw circles c2.draw(); c3.draw(); SetCursorPosition(1, 25); // Lower left corner on a standard console screen }