//********************************************************************
//  FoodItem.java       Author: Lewis and Loftus
//
//  Demonstrates indirect referencing through inheritance.
//********************************************************************

class FoodItem
{
   final private int CALORIES_PER_GRAM = 9;
   private int fatGrams;
   protected int servings;

   //-----------------------------------------------------------------
   //  Sets up this food item with the specified number of fat grams
   //  and number of servings.
   //-----------------------------------------------------------------
   public FoodItem (int fatGrams, int servings)
   {
      this.fatGrams = fatGrams;
      this.servings = servings;
   }

   //-----------------------------------------------------------------
   //  Computes and returns the number of calories in this food item
   //  due to fat.
   //-----------------------------------------------------------------
   private int calories ()
   {
      return fatGrams * CALORIES_PER_GRAM;
   }

   //-----------------------------------------------------------------
   //  Computes and returns the number of fat calories per serving.
   //-----------------------------------------------------------------
   public int caloriesPerServing ()
   {
      return (calories() / servings);
   }
}
