UNB/ CS/ David Bremner/ teaching/ java/ Customer.java
/**
   A bank customer
*/

public class Customer
{  /**
      Constructs a customer with a given number and PIN.
      @param aNumber the customer number
      @param PIN the personal identification number
   */
   public Customer(int aNumber, int aPin)
   {  customerNumber = aNumber;
      pin = aPin;
      accounts = new BankAccount[2];
      accounts[CHECKING_ACCOUNT] = new BankAccount();
      accounts[SAVINGS_ACCOUNT] = new BankAccount();
   }
   
   /** 
      Tests if this customer matches a customer number 
      and PIN.
      @param aNumber a customer number
      @param aPin a personal identification number
      @return true if the customer number and PIN match
   */
   public boolean match(int aNumber, int aPin)
   {  return customerNumber == aNumber && pin == aPin;
   }
   
   /** 
      Gets an account of this customer.
      @param account one of Customer.CHECKING_ACCOUNT
      or Customer.SAVINGS_ACCOUNT
      @return the selected account, or null if account 
      number not valid.
   */
   public BankAccount getAccount(int a)
   {  if (0 <= a && a < accounts.length)
         return accounts[a];
      else 
         return null;
   }
   
   public static final int CHECKING_ACCOUNT = 0;
   public static final int SAVINGS_ACCOUNT = 1;
   
   private int customerNumber;
   private int pin;
   private BankAccount[] accounts;
}