Quote:
Originally Posted by jccrumbl
Is my logic completely off here ... need to use a function instead of a method .. funtion to make the object rotate.
|
Certainly one of the most challenging questions I've seen posted in quite a while.

I really suggest after you read this and experiment a bit, you also look again at some references on Alice's while statements, methods and functions (either your text or Dick Baldwin's tutorials). There are a lot of details here that usually don't become clear until after the first reading or two. Also, Alice's (simplified) definitions for methods and functions are a bit different from true Java (and most other languages).
Anyway, here are some brief answers to your questions. Note that these comments apply strictly to Alice 2.0's implementation of method and functions.
1. The test condition in a while statement must evaluate to a boolean value (either true or false). Since an Alice method won't return
any value, you can't use a method call for the test condition.
2. You
can use a function, provided that the function returns a boolean value.
3. You can't run a method from a function, so you can't use a function to actually make an object rotate.
I enclosed a bit of sample code - not sure whether it will help or just make things more confusing.

But anyway, try changing the value of SAM in the function and see what happens.
Also note that, for some reason, in a function you can never delete the last return. But in the example - the code never gets there. The earlier returns (drag and drop from the bottom of the program window) will have returned the boolean value first.