Write a critter class Tigger
along with its movement and eating behavior.
All unspecified aspects of Tigger
use the default behavior.
Write the complete class with any fields, constructors, etc. necessary to implement the behavior.
Bouncing is what Tiggers do best!
The Tigger
's movement is to bounce up and down to increasingly large heights.
A Tigger
object is passed an integer when it is constructed that represents his initial bounce height.
(You may assume that this bounce height is at least 1.)
Whatever bounce height is passed, he will move that many steps NORTH, then that many steps SOUTH, then repeat for a bounce height 1 larger.
For example, a new Tigger(4)
will move NORTH 4 times, then SOUTH 4 times, then NORTH 5 times, then SOUTH 5 times, then NORTH 6 times, then SOUTH 6 times, and so on.
When a Tigger
finds food, he eats it and completely starts over his bouncing behavior.
That is, he starts over going NORTH on a bounce whose height is equal to the initial bounce height with which the Tigger
was constructed.
For example, the following would be a sequence of moves for a new Tigger(2)
.
Notice how he starts over every time he eats:
N,N, S,S, N,N,N, S,S,S, N,N,N,N, S,S,S,S, N (eats food), N,N, S,S, N,N,N, S,S,S, N,N,N,N, ...