Final Project - Turtle Graphics (as of 11/20)

Imagine a mechanical turtle that walks around the room under the control of a C++ program. The turtle holds a pen in one of two positions, up or down. While the pen is down, the turtle traces out shapes as it moves; while the pen is up, the turtle moves about freely while not writing anything. In this problem you will simulate the operation of the turtle and create a computerized sketchpad as well.

Use a 20x20 array floor which is initialized to zeros. Read commands from data files that we will provide. Keep track of the current position of the turtle at all times and whether the pen is currently up or down. Assume that the turtle always starts at position 0,0 of the floor with its pen up. The set of turtle commands your program must process are as follows:

Command   Meaning

u         pen up
d         pen down
n #       move # spaces north
s #       move # spaces south
e #       move # spaces east
w #       move # spaces west
p         print the 20x20 array
q         quit

Example:  Suppose the turtle is somewhere near the center of the floor. the following data file would draw and print a 13x13 square, leaving the pen in the up position:

e 12
s 12
w 12
n 12

As the turtle moves with the pen down, set the appropriate elements of the floor array to 1s. When the print command is given , wherever there is a 1 in the array, display some character that you choose. Wherever there is a zero display a blank.

  • Run your program with the following data files: turtle1 - turtle3 (will be also installed on y:\cs201)
  • Also make your own data file that will spell out the first and last initials of your name.
  • Your program should check for illegal characters used as commands.
  • If a command sends the turtle out-of-bounds, do not move the turtle.
  • Your program must compile to receive any credit.
  • Turn in: written pseudocode algorithm; printout of your code with comments; printout of test cases; and diskette.
  • This program is an individual effort.