1 15 16 package org.objectweb.jac.samples.bank; 17 18 import org.objectweb.jac.lib.java.util.Hashtable; 19 import org.objectweb.jac.lib.java.util.Vector; 20 import org.objectweb.jac.samples.contacts.Person; 21 22 31 32 public class Bank { 33 34 public long getBankNumber() { return bankNumber; } 35 public void setBankNumber( long bankNumber ) { this.bankNumber=bankNumber; } 36 37 38 protected long bankNumber; 39 40 41 protected Hashtable accounts = new Hashtable(); 42 43 protected Vector users = new Vector(); 44 45 public void addUser(Person user) { 46 if( !users.contains(user) ) { 47 users.add(user); 48 } 49 } 50 51 54 55 public Vector getUsers() { 56 return users; 57 } 58 59 63 64 public Bank(long bankNumber) { 65 this.bankNumber = bankNumber; 66 } 67 68 73 74 public Hashtable getAccounts() { 75 return accounts; 76 } 77 78 83 84 public void addAccount(Account account) { 85 accounts.put(new Long (account.accountNumber) , account) ; 86 account.setBank(this); 87 if( account.getOwner() != null ) { 88 users.add(account.getOwner()); 89 } 90 } 91 92 97 98 public void removeAccount(Account account) { 99 accounts.remove(new Long (account.accountNumber)); 100 } 101 102 108 109 public Account getAccount(long accountNumber) { 110 Account account; 111 account = (Account) accounts.get(new Long (accountNumber)); 112 return account; 113 } 114 115 119 120 public String toString() { 121 return ""+bankNumber; 122 } 123 124 125 } 126 | Popular Tags |