File

Submitted by: Submitted by

Views: 87

Words: 307

Pages: 2

Category: Other Topics

Date Submitted: 03/27/2014 11:58 AM

Report This Essay

Name:____________________________________ Date:_______ Pd:____

Exercise: Investigating Wombat World

[pic]

The Scenario:

Open up Greenfoot and the ‘wombats2’ scenario.

The Request:

While exploring wombat world answer the below exercise and simulation questions

Exercises:

1. Create 2 wombats in the world.

2. Create some leaves in the world

3. Invoke the move() method on a wombat. What does it do? What happens when the wombat reaches the edge of the world?

4. Invoke the turnleft() method on a wombat. Now make 2 wombats face each other(you may create a new wombat if you need to).

5. Invoke the canMove() method on your wombat. Does it always return true? Or can you find situations which it returns false?

6. Using one of your wombats, invoke the getLeavesEaten() method. It returns 0 but can you create a situation where it will not return 0? (In other words can you make your wombat eat some leaves?)

7. Invoke the setDirection(int direction) method. Provide a parameter value and see what happens. Which number corresponds to which direction? What happens when you type in a double and not an integer value?

8. Make sure you have a good number of leaves around the world. Invoke a wombats act() method several times. How is this different from the move() method? You can also access the act() method of all actors in the world at the bottom in the execution controls.

Simulation:

9. Create a new ‘wombats2’ scenario. Make it look exactly like the picture above.

10. Invoke the world act() method at the bottom of the screen. What happens when a wombat hits a rock?

11. What happens when you push the run button? Can you make the simulation move slower or faster?

12. Can you add rocks in the world so that the wombats will eat all of the leaves?