/**
   This program demonstrates an enumerated type.
*/

public class CreatureDemo
{
   public static void main(String[] args)
   {
      // Declare a Creature variable and assign it a value.
     Creature good;
	  Creature bad;
	  Creature small;
	  
	  good = Creature.HOBBIT;
	  bad = Creature.DRAGON;
	  small = Creature.ELF;
      
      // The following statement displays HOBBIT.
      System.out.println("I am a(n) " + good);
	  
	  // "Built in" methods
	  
	  System.out.println("I am a(n) " + bad.name());
	  
	  System.out.println("Is " + good + " the same as " +
	   bad + "? " + good.equals(bad) );
	  
	  if(good.compareTo(small) > 0)
	  	System.out.println(good + " is better than " + small + ".");
	  else if (good.compareTo(small) < 0)
	  	System.out.println(small + " is better than " + good + ".");
	  else
	  	System.out.println(small + " and " + good + " are the same.");
	
	  System.out.println("The position corresponding to bad is " + 
	    bad.ordinal());
	
	  System.out.println("I will now display all of the Creature objects.");
	  for (Creature c : Creature.values())
	  	System.out.println("\t" + c);
	}
}