View the step-by-step solution to:

# Description: The Logo language, which is popular among elementary school children, made the concept of turtle graphics famous.

Description:

The Logo language, which is popular among elementary school children, made the concept of turtle graphics famous. 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 without writing anything. In this problem, you will simulate the operation of the turtle and create a computerized sketchpad as well.

Use a N-by-M dynamic data structure called “floor” that is initialized to zeros (You can use a dynamic 2D array or one that we will talk about). The layout is as follows:
(0,0) … (M,0)

(0,N)…(N,M)

Read commands from an array that contains them. 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 and is headed down (south). The set of turtle commands your program must process are given below:

Command Meaning
-------------------------
1 Pen up
2 Pen down
3 Turn right (with respect to his current orientation)
4 Turn left (with respect to his current orientation)
5,10 Move forward (10 spaces in this case)
6 Print the 20-by-20 array
9 End of data (sentinel)

Directions
-------------------------
North
West East
South

Suppose that the turtle is somewhere near the center of the floor. The following “program” would draw and print a 12-by-12 square and end the with pen in the up position:

2
5,12
3
5,12
3
5,12
3
5,12
1
6
9

As the turtle moves with the pen down, set the appropriate elements of “floor” to 1’s. When the 6 command (print) is given, wherever there is a 1 in the floor, display an special character. Wherever there is a zero, display a blank.

Some requirements (for full credit, of course):
Use the console graphics lite code from our book to render the board and turtle position.
The turtle cannot go outside of the boundary. Error check!! Use a special exception class you create called TurtleGraphicsException to throw exceptions.
Create a class called TurtleGraphicsDriver as your “driver” program. Main() should be very small!!!!
Create a class called TurtleGraphics to handle the board and turtle.
Any other classes you can think of? How about inheritance? Would a Turtle class make sense?
Make your turtle graphics driver interactive (e.g. “Enter a command:” with a do-while loop), BUT, you must also be able to accept a list of commands from a text file that your driver reads in and runs. This is called a script.
Add other commands that you think would be cool.

Dear Student, you replied quite late. Our tutor asked for clarification from your... View the full answer

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

### -

Educational Resources
• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents