// Standard Shell for C++ Courseware // Copyright 1997 // College of Computer Science // Northeastern University Boston MA 02115 // This software may be used for educational purposes as long as this copyright // notice is retained at the top of all files // Should this software be modified, the words "Modified from Original" must be // included as a comment below this notice // All publication rights are retained. This software or its documentation may // not be published in any media either in whole or in part. /////////////////////////////////////////////////////////////////////////////// // Lab: Name and purpose of the lab or program // Goals: What students are going to learn from it // STUDENT NAME: %?%?% // STUDENT ID: %?%?% // DATE: %?%?% /////////////////////////////////////////////////////////////////////////////// #include "SWindows.h" // set up for windows #include "IOTools.h" // tools for safe I/O #include "Graphics.h" // graphics functions & RGB definition #include "RGBNames.h" // RGB names #include "Random.h" // random numbers #include "FileTool.h" // file tools #include "Text.h" // fonts and text #include "Delay.h" // delay controls #include "Basic2D.h" // 2D vector, point, rect #include "Polar2D.h" // 2D polar in radians or degrees #include "Scale.h" // 1D scaling #include "Scale2D.h" // 2D scaling #include "Plot2D.h" // 2D plotting #include "DblFcn.h" // double function template class // prototypes void main(); class myPoint { public: int x; int y; myPoint( int x0, int y0 ){ x = x0; y = y0; cout << "myPoint constructor type 2\n"; } myPoint() { // myPoint() : x(0), y(0) { cout << "..." } x = 0; y = 0; cout << "myPoint default constructor\n"; } ~myPoint() { cout << "myPoint destructor\n";} }; class StickPic { private: int size; myPoint pts [10]; // makes 10 calls to myPoint contructor public: StickPic() { // constructor cout << "StickPic contructor\n"; size = 0; } void addStick( int dx, int dy ){ // the current point in pts, // the coords of the end of the stick // relative to the 1st point // are written into pts[ size ] size++; pts[ size ].x = dx; pts[ size ].y = dy; } // what happens to pts[0] in the above code? Can you improve // the code? void Draw( int x0, int y0) ; // definitionj follows // void Erase( ); }; void StickPic::Draw( int x0, int y0 ){ MoveTo( x0, y0 ); // puts the pen at the point with coords x0, y0 for(int i=0; i