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;


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


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