Class BirdFeeder

java.lang.Object
  extended byBirdFeeder

public class BirdFeeder
extends Object

This class models a simple bird feeder.


Constructor Summary
BirdFeeder(int initialLevel)
          Construct a new bird feeder with the given amount of food.
 
Method Summary
 int feedTheBirds(int serving)
          Feed each bird the serving size each until the food is all gone.
 int getFoodLevel()
          Return the amount of food in the feeder.
 void setFoodLevel(int amount)
          Fill the feeder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BirdFeeder

public BirdFeeder(int initialLevel)
Construct a new bird feeder with the given amount of food.

Parameters:
initialLevel - the amount of food in the feeder in milliliters
Method Detail

feedTheBirds

public int feedTheBirds(int serving)
Feed each bird the serving size each until the food is all gone. Count the number of birds fed, including the last one that probably only got a partial portion.

Parameters:
serving - the amount of food per serving in milliliters
Returns:
the number of birds actually fed

getFoodLevel

public int getFoodLevel()
Return the amount of food in the feeder.

Returns:
the amount of food in the feeder in milliliters

setFoodLevel

public void setFoodLevel(int amount)
Fill the feeder.

Parameters:
amount - the new amount of food in the feeder in milliliters