Fish.java.html

  1  public class Fish
  2  {
  3     private int hungry;
  4     public static final int NOT_HUNGRY = 0;
  5     public static final int SOMEWHAT_HUNGRY = 1;
  6     public static final int VERY_HUNGRY = 2;  
  7     
  8     public void eat()
  9     {
 10        System.out.println("Yum!");
 11        hungry = NOT_HUNGRY;      
 12     }
 13  
 14     public void move()
 15     {
 16        if (hungry == VERY_HUNGRY)
 17        {
 18  	 System.out.println("Looking for food");
 19        }
 20        else
 21        {
 22  	 System.out.println("Looking for love");
 23           hungry++;
 24        }
 25     }
 26  }