BU CAS CS 113
Introduction to Computer Science II with Intensive C
Fall 1997


HW3 FAQ


Last Modified: Mon Nov 17 00:30:47 1997
Q. Once we defined the direction of the turtle to north, do we have to pass the address of variable "direction" to every functions in turtle.c because most of the functions will change the direction of turtle at the end.

A. We discussed this in class. You need to use a static global variable.


Q. In the functions MoveTurtle() and DrawTurtle(), is not the argument of angle needed, for you cannot figure out x or y via your formula without angle (a in your handout).

A. You need to know the angle, but that is known to the package. It IS NOT A PARAMETER! Read my previous email to the entire class.


Q. Is there any way for us to see the code behind hw3-draw.c?

A. Only if I show it to you. But i don't plan to, mostly because the code hasn't been cleaned up and commented, etc. but you don't really need it anyway. As long as you know what each function does and its prototype, you have everything you need.


Q. You mentioned in the homework that the lines of code that you gave us weren't the exact prototypes and I was wondering exactly what hw3-draw would send as arguments to the library.

A. What i gave shows the usage much like the usage lines in the comments in the text. You need to include the types, etc. YOU MAY NOT, however, add or delete arguments or change their types.


Q. How do I deal with the direction of the turtle?

A. A number of you have asked questions aobut the direction of the turtle, specifically how to store and retrieve it. I mentioned this problem on thursday and will tlak about this some more on tuesday. The thing you need to use is called a static global variable. This makes the variable available to all of the functions in your implementation but not to the client code. You can create a static gloabal variable by including the line

static double direction;
in your hw3-turtle.c file but outside of any function. (Put it just below any constants and above the function prototypes.)