import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
/*
 * TestButtonCoins.java
 *
 * Created on March 5, 2005, 3:41 PM
 */

/**
 *
 * @author Bill Kraynek
 */
public class TestButtonCoins {
    
    /** Creates a new instance of TestButtonCoins */
    public TestButtonCoins() {
        Coin penny = new Coin(0.01,"penny");
        Coin nickel = new Coin(0.05,"nickel");
        Coin dime = new Coin(0.10,"dime");
        Coin quarter = new Coin(0.25,"quarter");
        Coin halfDollar = new Coin(0.50,"halfDollar");
        Coin dollar = new Coin(1.00,"dollar");
        JFrame theFrame = new JFrame("Coins");
        theFrame.setSize(600,700);
        theFrame.setDefaultCloseOperation(theFrame.EXIT_ON_CLOSE);
        theFrame.setLayout(new FlowLayout(FlowLayout.CENTER, 300,20));
        CoinButton pennyButton = new CoinButton(penny);
        theFrame.add(pennyButton);
        theFrame.add(pennyButton.getCoinLabel());
        CoinButton nickelButton = new CoinButton(nickel);
        theFrame.add(nickelButton);
        theFrame.add(nickelButton.getCoinLabel());
        CoinButton dimeButton = new CoinButton(dime);
        theFrame.add(dimeButton);
        theFrame.add(dimeButton.getCoinLabel());
        CoinButton quarterButton = new CoinButton(quarter);
        theFrame.add(quarterButton);
        theFrame.add(quarterButton.getCoinLabel());
        CoinButton halfDollarButton = new CoinButton(halfDollar);
        theFrame.add(halfDollarButton);
        theFrame.add(halfDollarButton.getCoinLabel());
        CoinButton dollarButton = new CoinButton(dollar);
        theFrame.add(dollarButton);
        theFrame.add(dollarButton.getCoinLabel());
        theFrame.add(CoinButton.getTotalLabel());
        JButton purseButton = new JButton("Show Purse");
        purseButton.addActionListener(new ShowPurseAction());
        theFrame.add(purseButton);
        theFrame.setVisible(true);
    }// end constructor
    
    class ShowPurseAction implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            Collections.sort(CoinButton.getPurse());
            JOptionPane.showMessageDialog(null,"Purse contains " + CoinButton.getPurse());
        }// end actionPerformed
    }// end ShowPurseAction
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new TestButtonCoins();
    }// end main
    
}

