View Javadoc

1   /**
2    * 
3    */
4   package org.sourceforge.jemm.sample.demo1.model.orig;
5   
6   import org.sourceforge.jemm.Entity;
7   
8   /**
9    * A Savings account owned by Person (extension of basic Account to include
10   * interest handling.).
11   * 
12   * @author Paul Keeble
13   */
14  @Entity
15  public class SavingsAccount extends Account {
16  	double lastInterestAmount;
17  
18  	/**
19  	 * Create a SavingsAccount with an initial balance of 0.
20  	 */
21  	public SavingsAccount() {
22  		lastInterestAmount = 0;
23  	}
24  
25  	/**
26  	 * Create a SavingsAccount with the given initial balance.
27  	 * 
28  	 * @param initialBalance
29  	 *            The account initial balance.
30  	 */
31  	public SavingsAccount(double initialBalance) {
32  		super(initialBalance);
33  	}
34  
35  	/**
36  	 * Add yearly interest to the account using the given interest rate.
37  	 * 
38  	 * @param interestRate
39  	 *            The yearly interest rate to add.
40  	 */
41  	public synchronized void addInterest(double interestRate) {
42  		lastInterestAmount = balance * interestRate / 100;
43  		balance = balance + lastInterestAmount;
44  	}
45  }