package atm;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;

/**
   A simulation of an automatic teller machine
*/

public class ATMSimulation
{  public static void main(String[] args)
   {  ATM frame = new ATM();
      frame.setTitle("Javabank");      
      frame.show();
   }
}

class ATM extends JFrame implements ActionListener
{  /**
      Constructs the user interface of the ATM application.
   */
   public ATM()
   {  final int FRAME_WIDTH = 500;
      final int FRAME_HEIGHT = 200;
      setSize(FRAME_WIDTH, FRAME_HEIGHT);
      
      addWindowListener(new WindowCloser());

      pad = new KeyPad();

      display = new JTextArea(4, 20);
      
      aButton = new JButton("  A  ");
      aButton.addActionListener(this);

      bButton = new JButton("  B  ");
      bButton.addActionListener(this);

      cButton = new JButton("  C  ");
      cButton.addActionListener(this);
      
      // add components to content pane

      JPanel buttonPanel = new JPanel();
      buttonPanel.setLayout(new GridLayout(3, 1));
      buttonPanel.add(aButton);
      buttonPanel.add(bButton);
      buttonPanel.add(cButton);
      
      Container contentPane = getContentPane();
      contentPane.setLayout(new FlowLayout());
      contentPane.add(pad);
      contentPane.add(display);
      contentPane.add(buttonPanel);

      setState(START_STATE);      
   }
   
   /** 
      Sets the current customer number to the keypad value
      and sets state to PIN.
   */
   public void setCustomerNumber() 
   {}

   /** 
      Gets PIN from keypad, finds customer in bank.
      If found sets state to ACCOUNT, else to START.
   */
   public void selectCustomer()
   {}
   
   /** 
      Sets current account to checking or savings. Sets 
      state to TRANSACT
      @param account one of Customer.CHECKING_ACCOUNT
      or Customer.SAVINGS_ACCOUNT
   */
   public void selectAccount(int account)
   {}

   /** 
      Withdraws amount typed in keypad from current account. 
      Sets state to ACCOUNT. 
   */
   public void withdraw()
   {}

   /** 
      Deposits amount typed in keypad to current account. 
      Sets state to ACCOUNT. 
   */
   public void deposit()
   {}

   /** 
      Sets state and updates display message.
      @param state the next state
   */
   public void setState(int newState)
   { }
   
   private int state;
   private int customerNumber;
   private Customer currentCustomer;
   private BankAccount currentAccount;
   private Bank theBank;
   
   private JButton aButton;
   private JButton bButton;
   private JButton cButton;
   
   private KeyPad pad;
   private JTextArea display;
   
   private static final int START_STATE = 1;
   private static final int PIN_STATE = 2;
   private static final int ACCOUNT_STATE = 3;
   private static final int TRANSACT_STATE = 4;

    /**
       Reagiert auf Knopfdruecke je nach gedruecktem Knopf und Zustand.
    */
    public void actionPerformed(ActionEvent event) {
    }
}

   class WindowCloser extends WindowAdapter
   {  public void windowClosing(WindowEvent event)
      {  System.exit(0);
      }
   }
