Preston Decker's Fourth CS151 Homework

Explanations

  • 1.Our task was to create functions/files which would allow us to use Terminal to give the python Turtle program instructions to draw shapes.
  • 2. The first task was to create a program in BBedit that allowed me to input commands to terminal which would cause the Turtle to draw a shape after the commands were entered. This was accomplished by first defining a variety of commands in my drawShape function -such as making the forward() equivalent to 'f'- in terms of letters. My main function ran a while loop that allowed me to continue entering commands until I broke out by pressing the return button. A loop previously created in my processString function -the processString function was called at the end of my main function- then made Turtle run all the commands I had just entered.

    3. The second task was to create a program in BBedit that allowed me to use terminal to read commands from another file into turtle which would then draw the shape directed by the commands. This was done by using the sameprocessString and drawShape functions mentioned above. The main function was changed so that it would take a different file as raw input, and then read information (which had to use commands defined in my drawShape from a line of this file, and then process this information and run it in turtle (using the processString funtion), creating the shape.

    I need to thank Mac Simpson for help with this project as well as supplying code for this project. The square was the creation of my first task using the commands fffflllffffrrrllllllfffflllffff. The triangle was the creation of my second task.