Sunday, May 11, 2008

Tut 4 - Supplementary Problem #1


Problem #1: Given a scenario with 2 sharks and 2 fish.


  • (a) Write a world-level method, called sharkEat1, that
    checks the following: If shark is near to the fish within 3 meters, shark moves toward the fish and eats it. If not, shark turns around and moves away 2 meters.


  • (b) Write a world-level method, called sharkEat2, that checks the following:
    If shark2 is near to the goldfish within 3 meters, shark2 moves toward the goldfish and eats it. If not, shark2 turns around and moves away 2 meters.



Call both methods from my first world method.