Squeak Program 2: Recursion
Draw a spiral made out of squares (see picture below)
Extra: Implement the "turtle" tree program in Smalltalk
Fall 2005

  1. Define method constantAngleSpiral
         constantAngleSpiral: sidelength angle: angle
    	"Bot new constantAngleSpiral: 5 angle: 121"
    	sidelength < 500
     	ifTrue: [ self go: sidelength.
    		  self turnLeft: angle.	
    		  self constantAngleSpiral: (sidelength+5) angle:angle].
    
    
     
    Bot new constantAngleSpiral: 5 angle: 121

  2. Method for various spirals
        spiral: limit numtimes: n initangle: angle increment: inc distance: dist
         "Bot new spiral: 1 numtimes: 90 initangle: 2 increment: 20 distance: 30.
          Bot new spiral: 1 numtimes: 72 initangle: 40 increment: 30 distance: 30.
          Bot new spiral: 1 numtimes: 100 initangle: 40 increment: 5 distance: 23"
    	limit < n
     	ifTrue: [ self go: dist.
    		  self turnLeft: angle.	
    		  self spiral: (limit+1) numtimes: n initangle:(angle+inc)
    				increment: inc distance: dist].
    
      
  3. Try these commands:

  4. Bot new spiral: 1 numtimes: 72 initangle: 40 increment: 30 distance: 30

  5. Bot new spiral: 1 numtimes: 100 initangle: 40 increment: 5 distance: 23

  6. Assignment 1: Change the spiral method above to draw a square instead of a line to duplicate this picture.

  7. Assignment 2: Draw this tree (more hints to follow)