//*****************************************************************************
// Create and use a complex enum
// A enum can be used as a class, with constructor, fields and methods.
//*****************************************************************************

public class pgm2       
{
    public enum Coins 
    {
        PENNY(1), NICKEL(5), DIME(10), QUARTER(25), DOLLAR(100);   //complex enum

        private int amount;					   //field
        
        Coins(int amt)						   //constructor							
        {
            this.amount = amt;
        }
    }

    public static void main(String[] args)
    {
        Coins c = Coins.QUARTER;
        int val = c.amount;

        if (c == Coins.QUARTER);                        
            System.out.println("A " + c + " is worth " + c.amount);
            System.out.println();

        for (Coins c2 : Coins.values()) {            	//using enum in a loop
            System.out.println(c2 + "\t is worth " + c2.amount);
        }
        System.out.println();

        switch(c)                            		//using enum in a switch stmt
        {
            case PENNY:   
                 System.out.println("You have a " + c + " worth " + c.amount + " pennies"); 
                 break;
            case NICKEL:  
                 System.out.println("You have a " + c + " worth " + c.amount + " pennies"); 
                 break;     
            case DIME:    
                 System.out.println("You have a " + c + " worth " + c.amount + " pennies"); 
                 break;   
            case QUARTER: 
                 System.out.println("You have a " + c + " worth " + c.amount + " pennies"); 
                 break;   
            case DOLLAR:  
                 System.out.println("You have a " + c + " worth " + c.amount + " pennies"); 
                 break;
        }
    }
}