/** 
    @author Elizabeth Adams 
	 variant of SavingsAccount from Lab15 - makes use of local getAccountNumber()
*/
public class SavingsAccount extends BankAccount
{
    private double rate; //= 0.025;
	 private int savingsNumber; // = 0;
	 private String accountNumber;
	 
	 public SavingsAccount (String name, double initBalance)
	 {
	    super (name, initBalance);
       String temp;
	    rate = 0.025;
		 savingsNumber = 0;
       temp = super.getAccountNumber();
   //	 System.out.println (" in constructor SavingsNumber is " + savingsNumber);  // DEBUG
       accountNumber = temp + "-" + savingsNumber;
   //	 System.out.println (accountNumber);                                 // DEBUG
	// savingsNumber = savingsNumber + 1;                // ERRONEOUS
	 }// end constructor

	  // copy constructor described on page 569 of text	 
	 public SavingsAccount (SavingsAccount oldSavingsAccountObject, double initBalance)
	 {
	    super(oldSavingsAccountObject, initBalance);  
       savingsNumber = savingsNumber + 1;  // statement needed 2B here not in get accountNumber()!
	  }// end copyconstructor
	    
	  public void postInterest ()
	  {
	      // calculates one months worth of interest on the balance 
			// and deposits it into the account
			double tempBalance;
			tempBalance = getBalance();   
			tempBalance = tempBalance + tempBalance * (1.0/12.0) * rate;
			setBalance(tempBalance);
	  }// end postInterest
	  
	   /**accessor method to account number
   	@return the account number*/
       public String getAccountNumber()
      {
		  String temp;
	     temp = super.getAccountNumber();  
  	  	//  System.out.println (savingsNumber);     DEBUG STATEMENT
  	     accountNumber = temp + "-" + savingsNumber;	
  	     return accountNumber;
      } // end overRidden getAccountNumber;
		
}// end class		 
