{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# solutions10 - CSCI-1100 Computer Science I Rensselaer...

This preview shows pages 1–3. Sign up to view the full content.

CSCI-1100 Computer Science I Rensselaer Polytechnic Institute Spring 2004 Studio 10 -- Solutions 1. #include "Canvas.h" // A Logo Turtle-like Pen class for drawing on a canvas class Pen { public: Pen (const Canvas& can); // create a pen for a canvas void GoTo(double x, double y); // move pen to a new position void Move(double dist); // move ahead a specified distance void Turn(double degrees); // turn pen counterclockwise void Direction(double angle); // turn pen to specified direction double GetXLoc(); // return pens current x coordinate double GetYLoc(); // return pens current y coordinate private: Canvas c; // canvas for pen double xloc; // current x location of pen double yloc; // current y location of pen double direction; // current direction of pen }; Pen.h

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
#include "Canvas.h" #include "pen.h" #include "mathutils.h" #include <cmath> using namespace std; // implementation of the Pen constructor Pen::Pen(const Canvas& can): c(can) { xloc = 0.0; yloc = 0.0; direction = 0.0; } // go to a specified coordinate void Pen::GoTo(double x, double y) { xloc = x; yloc = y; }
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

solutions10 - CSCI-1100 Computer Science I Rensselaer...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online