

import java.util.*;

/**
 * The ZooAnimal class represents an animal in a zoo.  All ZooAnimals have names
 * and become hungry periodically and have to eat.  Subclasses should override
 * isHungry based on the particular percentage of time the animal represented
 * by the subclass gets hungry.
 */
public abstract class ZooAnimal {
  /**
   * All ZooAnimals have names.
   */
  protected String name;

  /**
   * This random number generator is private so that no one can reset its seed.
   */
  private Random random = new Random(1000L);

  /**
   * Subclasses are expected to reuse this constructor.
   */
  public ZooAnimal(String name) {
    this.name = name;
  }

  /**
   * Returns the name of this ZooAnimal.
   */
  public String getName() {
    return name;
  }

  /**
   * Returns the next random number.
   */
  protected double nextRandom() {
    return random.nextDouble();
  }

  /**
   * Subclasses must override this method to determine when they are hungry.
   */
  public abstract boolean isHungry();

  /**
   * Just print to the screen the eating status.
   */
  public void eat() {
    System.out.println(name + " is eating");
  }

} // ZooAnimal