Source of BankAccountController.java


  1: //BankAccountController.java
  2: //Adapted from an example by Tony Sintes.

  4: import java.awt.event.ActionListener;
  5: import java.awt.event.ActionEvent;

  7: public class BankAccountController 
  8: implements ActionListener
  9: {
 10:     private BankAccountView  view;
 11:     private BankAccountModel model;

 13:     //Constructor
 14:     public BankAccountController(BankAccountView  view,
 15:                                  BankAccountModel model)
 16:     {
 17:         this.view  = view;
 18:         this.model = model;
 19:     }

 21:     //Responds to a deposit or withdrawal event
 22:     public void actionPerformed(ActionEvent e)
 23:     {
 24:         if (e.getActionCommand().equals("Withdraw"))
 25:             model.withdrawFunds(view.getAmount());
 26:         if (e.getActionCommand().equals("Deposit"))
 27:             model.depositFunds(view.getAmount());
 28:     }
 29: }