Turtle Class Reference

#include <turtlelib.h>

List of all members.


Detailed Description

Definition at line 11 of file turtlelib.h.

Public Member Functions

 Turtle ()
 Constructs a Turtle object and intializes its heading to North (up) and position to (0, 0).
 Turtle (double x, double y)
 Constructs a Turtle object and intializes its heading to North (up) and position to the x- and y-coordinates.
void forward (double distance)
 Move this turtle forwards the given distance in the direction it is heading.
void backward (double distance)
 Move this turtle backwards the given distance from the direction it is heading.
void left (double degrees)
 Turn this turtle to the left (counter-clockwise) the given number of degrees from the current direction it is heading.
void right (double degrees)
 Turn this turtle to the right (clockwise) the given number of degrees from the current direction it is heading.
double getHeading () const
 Returns the current heading (direction) in degrees for this turtle as the number of degrees clockwise from the North (up).
void setHeading (double degrees)
 Turn this turtle to the given heading (direction).
double getX () const
 Returns the current x-coordinate of this Turtle.
double getY () const
 Returns the current y-coordinate of this Turtle.
void moveTo (double x, double y)
 Move this turtle to the given x and y location without drawing.
void moveTo (string prompt)
 Move this turtle to the position of the mouse when clicked.
bool isPenDown () const
 Checks whether the pen is down for this turtle.
void setPenDown (bool down)
 Enables or disables drawing when this turtle moves.
void print (string message)
 Prints a text message at the current Turtle position.
void print (double number)
 Prints a number at the current Turtle position.
void sleep (int millis)
 Stops program execution for the specified delay time.
void clear ()
 Clears the Turtle window.
string getString (string prompt)
 Prompts the user for a string.
int getInt (const string &prompt)
 Prompts the user for an integer.
double getDouble (const string &prompt)
 Prompts the user for a floating-point value.


Constructor & Destructor Documentation

Turtle::Turtle (  ) 

Constructs a Turtle object and intializes its heading to North (up) and position to (0, 0).

Turtle::Turtle ( double  x,
double  y 
)

Constructs a Turtle object and intializes its heading to North (up) and position to the x- and y-coordinates.


Member Function Documentation

void Turtle::backward ( double  distance  ) 

Move this turtle backwards the given distance from the direction it is heading.

Parameters:
distance The distance to move

void Turtle::clear (  )  [inline]

Clears the Turtle window.

Definition at line 133 of file turtlelib.h.

void Turtle::forward ( double  distance  ) 

Move this turtle forwards the given distance in the direction it is heading.

Parameters:
distance The distance to move

double Turtle::getDouble ( const string &  prompt  )  [inline]

Prompts the user for a floating-point value.

Parameters:
prompt The message to display while waiting for user input.
Returns:
the number that the user entered.

Definition at line 154 of file turtlelib.h.

double Turtle::getHeading (  )  const [inline]

Returns the current heading (direction) in degrees for this turtle as the number of degrees clockwise from the North (up).

Returns:
The current heading in degrees between 0 and 360.

Definition at line 58 of file turtlelib.h.

References T_INIT_HEADING.

int Turtle::getInt ( const string &  prompt  )  [inline]

Prompts the user for an integer.

Parameters:
prompt The message to display while waiting for user input.
Returns:
the number that the user entered.

Definition at line 147 of file turtlelib.h.

string Turtle::getString ( string  prompt  )  [inline]

Prompts the user for a string.

Parameters:
prompt The message to display while waiting for user input.
Returns:
the string that the user entered.

Definition at line 140 of file turtlelib.h.

double Turtle::getX (  )  const [inline]

Returns the current x-coordinate of this Turtle.

Returns:
The x-coordinate

Definition at line 75 of file turtlelib.h.

double Turtle::getY (  )  const [inline]

Returns the current y-coordinate of this Turtle.

Returns:
The y-coordinate

Definition at line 82 of file turtlelib.h.

bool Turtle::isPenDown (  )  const [inline]

Checks whether the pen is down for this turtle.

Returns:
true if the pen is down else false

Definition at line 102 of file turtlelib.h.

void Turtle::left ( double  degrees  ) 

Turn this turtle to the left (counter-clockwise) the given number of degrees from the current direction it is heading.

Parameters:
degrees The number of degrees to turn.

void Turtle::moveTo ( string  prompt  ) 

Move this turtle to the position of the mouse when clicked.

Parameters:
prompt The message to display while waiting for the mouse click.

void Turtle::moveTo ( double  x,
double  y 
)

Move this turtle to the given x and y location without drawing.

Parameters:
x The x-coordinate to which to move this Turtle.
y The y-coordinate to which to move this Turtle.

void Turtle::print ( double  number  ) 

Prints a number at the current Turtle position.

Parameters:
number The number to display.

void Turtle::print ( string  message  ) 

Prints a text message at the current Turtle position.

Parameters:
message The string to display.

void Turtle::right ( double  degrees  ) 

Turn this turtle to the right (clockwise) the given number of degrees from the current direction it is heading.

Parameters:
degrees The number of degrees to turn.

void Turtle::setHeading ( double  degrees  ) 

Turn this turtle to the given heading (direction).

Headings are based on the degrees of the compass with zero (0) degrees meaning to point straight up and turning clockwise through 360 degrees.

Parameters:
degrees The new heading for this Turtle.

void Turtle::setPenDown ( bool  down  )  [inline]

Enables or disables drawing when this turtle moves.

Parameters:
down Set true to enable drawing and false to disable drawing.

Definition at line 108 of file turtlelib.h.

void Turtle::sleep ( int  millis  )  [inline]

Stops program execution for the specified delay time.

Parameters:
millis The delay in milliseconds.

Definition at line 126 of file turtlelib.h.


The documentation for this class was generated from the following file:
Generated on Sun Aug 31 21:19:56 2008 for Student API by  doxygen 1.4.7