View Javadoc
1   package ejava.examples.ejbsessionbank.bo;
2   
3   import java.io.Serializable;
4   
5   public class Account implements Serializable {
6       private static final long serialVersionUID = -610133933394333468L;
7       private long id;
8       private String accountNumber;
9       private double balance;
10      
11      public Account() {}
12      public Account(long id) { setId(id); }
13      public Account(long id, String accountNumber) {
14          setId(id);
15          setAccountNumber(accountNumber);
16      }
17      
18      public long getId() {
19          return id;
20      }
21      private void setId(long id) {
22          this.id = id;
23      }
24      public void deposit(double amount) {
25          setBalance(getBalance() + amount); 
26      }
27      public void withdraw(double amount) {
28          setBalance(getBalance() - amount); 
29      }    
30      public String getAccountNumber() {
31          return accountNumber;
32      }
33      public void setAccountNumber(String accountNumber) {
34          this.accountNumber = accountNumber;
35      }
36      public double getBalance() {
37          return balance;
38      }
39      private void setBalance(double balance) {
40          this.balance = balance;
41      }        
42      public String toString() {
43          StringBuilder text = new StringBuilder();
44          text.append("id=" + id);
45          text.append(", acctnum=" + accountNumber);
46          text.append(", bal=$" + balance);
47          return text.toString();
48      }
49  }