View Javadoc

1   /**
2    * 
3    */
4   package org.sourceforge.jemm.sample.demo1.model.orig;
5   
6   import org.sourceforge.jemm.Entity;
7   
8   /**
9    * An Account held by a Person.
10   * 
11   * @author Paul Keeble
12   */
13  @Entity
14  public class Account {
15  	double balance;
16  
17  	/**
18  	 * Create a new account with an initial balance of 0.
19  	 */
20  	public Account() {
21  		this.balance = 0;
22  	}
23  
24  	/**
25  	 * Create a new account with the given initial balance.
26  	 * 
27  	 * @param initialBalance
28  	 *            The initial account balance.
29  	 */
30  	public Account(double initialBalance) {
31  		this.balance = initialBalance;
32  	}
33  
34  	/**
35  	 * Returns the balance on the account.
36  	 * 
37  	 * @return The balance of the account.
38  	 */
39  	public synchronized double getBalance() {
40  		return balance;
41  	}
42  
43  	/**
44  	 * Deposit the given about into the account, increasing the balance.
45  	 * 
46  	 * @param amount
47  	 *            The amount to deposit.
48  	 */
49  	public synchronized void deposit(double amount) {
50  		balance += amount;
51  	}
52  }