KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > tests > jfun > models > BankAccount


1 package tests.jfun.models;
2
3 public class BankAccount extends LifecycleTransition{
4   private String JavaDoc id;
5   private char[] chars;
6   private BankAccount joint;
7   public int balance;
8   private boolean destroyed = false;
9   public void destroy(){
10     destroyed = true;
11   }
12   public boolean isDestroyed(){
13     return destroyed;
14   }
15   public BankAccount(){
16     
17   }
18   public BankAccount(String JavaDoc id, int balance){
19     this.id = id;
20     this.balance = balance;
21   }
22   public char getChar(int ind){
23     return chars[ind];
24   }
25   public void setChar(int ind, char c){
26     if(chars==null)
27       chars = new char[10];
28     chars[ind] = c;
29   }
30   public BankAccount getThis(){
31     return this;
32   }
33   public int getBalance() {
34     return balance;
35   }
36   public void setBalance(int balance) {
37     this.balance = balance;
38   }
39   public String JavaDoc getId() {
40     return id;
41   }
42   public void setId(String JavaDoc id) {
43     this.id = id;
44     if(chars==null)
45       this.chars = id.toCharArray();
46   }
47   public String JavaDoc toString(){
48     return "{id="+id+", balance="+balance+"}";
49   }
50   private static final class MyOwnBankAccount extends BankAccount{}
51   public static BankAccount create(String JavaDoc id, int balance){
52     final BankAccount ret = new MyOwnBankAccount();
53     ret.id = id;
54     ret.chars = id.toCharArray();
55     ret.balance = balance;
56     return ret;
57   }
58   
59
60   public BankAccount getJoint() {
61     return joint;
62   }
63   public void setJoint(BankAccount joint) {
64     this.joint = joint;
65   }
66   public void err(String JavaDoc msg){
67     throw new RuntimeException JavaDoc(msg);
68   }
69
70 }
71
Popular Tags