Wombats

Submitted by: Submitted by

Views: 315

Words: 388

Pages: 2

Category: Other Topics

Date Submitted: 03/02/2012 09:20 PM

Report This Essay

P. 8, Exercise 1.3:

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

The wombat was unable to move (it returned false) when at the edge of the world, unless the wombat was turned so that it was positioned parallel to the edge.

P8, Exercise 1.4: Using a newly created wombat, the getLeavesEaten() method will always return zero. Can you create a situation in which the result of this method is not zero? (In other words: can you make your wombat eat some leaves?)

Yes. I used the voidTurnLeft() and canMove() methods until I had moved my wombat to a leaf. Once there, I used the Act button to make the wombat eat the leaf. The getLeavesEaten() result was 1.

P9, Exercise 1.5: Invoke the setDirection(int direction) method. Provide a parameter value and see what happens. Which number corresponds to which direction? Write them down.

0 = straight, horizontal

1 = 180 degree turn, wombat is on it’s back

2 = 90 degree turn, wombat is facing right

3 = 270 degree turn, wombat is on it’s head, facing left.

What happens when you type in a number greater than 3?

I typed in 5 and the wombat didn’t change directions.

What happens if you provide input that is not a whole number, such as a decimal number (2.5) or a word (three)?

I typed in both 2.5 and three and I was unable to enter either. Clicking OK didn’t do anything.

P12, Exercise 1.13: Asteroids have an inherent stability. Each time they get hit by a bullet, the stability decreases. When it reaches zero, they break up. What is their initial stability value after you create them? By how much does the stability decrease from a single hit by a bullet? (Hint: Just shoot an asteroid once, and then check the stability again. Another hint: To shoot the asteroid, you must run the game. To use the object menu, you must pause the game first.)

When the asteroid is first created, before a bullet has hit it, it’s stability is 64. After...