Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Turtle : writting a programme

807600Nov 16 2007 — edited Nov 18 2007
can any one help me how to write a java programme for this ? it is using text, not graphiic.

Use a 20-by-20 array floor that is initialized to zeros. 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. The set of turtle commands your application must
process are shown in the following table.
Command Meaning
1 Pen up
2 Pen down
3 Turn right
4 Turn left
5,x Move forward x spaces (e.g. 5,10 move forward 10 spaces)
6 Display the 20-by-20 array
9 End of data (sentinel)


example.
Turtle graphics commands.
Suppose that the turtle is somewhere near the center of the floor. The following
?program? would draw and display a 12-by-12 square, leaving the pen in the up position:
2
5,12
3
5,12
3
5,12
3
5,12
1
6
9
x x x x x x x x x x x x
x x
x x
x x
x x
x x
x x
x x
x x
x x
x x
x x x x x x x x x x x x
Turtle Commands Turtle graphic
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 16 2007
Added on Nov 16 2007
2 comments
292 views