Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Recusive method
Old
ZolaFox
Guest
 
Status:
Posts: n/a
Default Recusive method - 11-28-2010, 11:54 PM

I am having difficulty with this project. Can someone please help?
Recursive Sailing
Create a sea world with a boat and an island. Position the island some distance
away from the boat, as shown in Figure 8-26. Write a method named sailTo,
which has an Object parameter. The method should cause the boat to move one
meter toward the object and then recursively call itself until the boat has reached
the object. Test the method by calling it and passing the island as the argument.
   
Reply With Quote
Old
savan12986
Guest
 
Status:
Posts: n/a
Default 11-29-2010, 10:37 PM

first off, set the boat to point at the island. then make a method with an if/then statement in it, and a parameter which is an object

in the if/then make it check if the boat is at least a certain distance away from the parameter

if so, have the boat move 1 meter towards the parameter

if else do nothing

outside the if else call the method and click yes I understand what I am doing in the popup window.

in my first method, call the method, and set the island as the target
   
Reply With Quote
recursive
Old
ZolaFox
Guest
 
Status:
Posts: n/a
Default recursive - 12-01-2010, 12:40 PM

Thank you, I will try this evening, but I could not make my stop.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.