| Name: | Grader: | Score: |
For each question below, you will be asked to experiment with the code by changing the values given as parameters. Feel free to copy the code given into a Visual J++ project and watch it run.
Consider the behavior given in CircleBehavior.java which moves a given shape around in a circular path (in fact, this implementation is similar to many of your own solutions). This behavior works well as named when the angle change given is small, e.g., less than ten degrees. However, it may trace a much different shape when the angle is larger.
Note: if you actually run this code, the path might be much more obvious if you replace the Step routine shown above by :
Consider the applet linked below which combines two behaviors you have seen or written previously by adding them both to a single shape. Run the applet for a variety of starting values for both MoveBehavior and CircleBehavior by changing only the parameters given them in the applet. To better understand the path traced out by the moving shape, the applet also adds a behavior that leaves a trail behind the moving shape.
Consider the following applet which combines two instances of a behavior similar to the CircleBehavior above but defined more intuitively for making circles: in terms of a diameter, seconds to move around the circle, and direction to move around the circle. Again, by varying the values used to initialize these behaviors you will see that a single complex behavior can result from two very simple behaviors.
What happens if the fixed circle is bigger than rolling one? smaller?
equal? very close to equal?
What happens if the pen moves more quickly than the rolling circle?
more slowly? the same rate? very close to the same?
What happens when the pen and the rolling circle both move
counter-clockwise, i.e., in the positive direction? both clockwise, i.e.,
the negative direction? in opposite directions?
What happens if you use the same initial values in for both circles?
opposite values?
Modify the Spirograph class above so that the rolling circle travels
around the inside of the fixed circle rather than around the outside. (Hint: the
changes should be very minor and only in code within the Spirograph
class.) Does this allow you to draw different shapes than you could before?