codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Help with Java Script  judjud at 03:21 on Wednesday, February 16, 2005
 

Please help with Java Coding*****************The Logo language, which is popular among young computer users made the concept of Turtle graphics famous, Imagine a mechanical turtle that walks around the room under the control of a JavaScript program. The turtle holds the pen in one of two positions. Up or down. When the pen is down, the turtle traces out shapes as it moves. When 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 20 by 20 array floor that is initialized to Zeros. Read commands from an array that contains them. Assume the turtle always starts at position (0,0) of the floor with its pen up. The commands your script must process are as follows:
Command Meaning
1 Pen up
2 Pen down
3 Turn right
4 Turn left
5, 10 Move forward 10 spaces or a number other than ten
6 Print the 20 by 20 array
9 End of data (sentinel)

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 then leave the 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 the array floor to 1s. When the 6 (print) command is given, display an asterisk wherever there is a 1 in the array. Wherever there is a zero display a blank. Write a script to implement the turtle graphics capabilities discussed here.









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: ASP.NET web controls
•  netscape 6 browser problem
•  Re: Print .doc file from the website using System.Diagnostics.Process
•  Re: Print and print preview file on the website without using the File - Print on the IE
•  Re: JavaSript Problem In Mac Safari Browser
•  Re: DHTML div positionning Problem
•  Convert script to NS6 compatible - Please Help!
•  Re: Fullscreen code
•  Re: iframe targeting


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005