Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
We have five instance variables:
picture – the file name representing the JPEG of this animal
food – the type of food this animal eats. Right now, there can be only two values: meat or grass.
hunger – an int representing the hunger level of the animal. It changes depending on when (and how much) the animal eats.
boundaries – values representing the height and width of the ‘space’ (for example, 640 x 480) that the animals will roam around in.
location – the X and Y coordinates for where the animal is in the space.
We have four methods:
makeNoise () – behavior for when the animal is supposed to make noise.
eat() – behavior for when the animal encounters its preferred food source, meat or grass.