KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > samples > bank > AccountManager


1 /*
2   Renaud Pawlak, pawlak@cnam.fr, CEDRIC Laboratory, Paris, France.
3   Lionel Seinturier, Lionel.Seinturier@lip6.fr, LIP6, Paris, France.
4
5   JAC-Core is free software. You can redistribute it and/or modify it
6   under the terms of the GNU Library General Public License as
7   published by the Free Software Foundation.
8   
9   JAC-Core is distributed in the hope that it will be useful, but
10   WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13   This work uses the Javassist system - Copyright (c) 1999-2000
14   Shigeru Chiba, University of Tsukuba, Japan. All Rights Reserved. */

15
16 package org.objectweb.jac.samples.bank;
17
18 import org.objectweb.jac.lib.java.util.*;
19
20 /**
21  * Defines a manager for all the created banks and accounts of the
22  * bank sample.<p>
23  *
24  * @see Account
25  * @see Bank
26  *
27  * @author <a HREF="mailto:maxime@aopsys.com">Maxime Pawlak</a>
28  * @author <a HREF="mailto:pawlak@cnam.fr">Renaud Pawlak</a> */

29
30 public class AccountManager {
31
32    /** Stores the banks that are managed by this manager. */
33    protected Hashtable banks = new Hashtable();
34    
35    /**
36     * Returns a table that links the banks with their numbers.<p>
37     *
38     * @return a hashtable (numbers -> banks)
39     */

40
41    public Hashtable getBanks () {
42       return banks;
43    }
44
45    /**
46     * Adds an existing bank to this manager.<p>
47     *
48     * @param bank the bank to add */

49
50    public void addBank (Bank bank) {
51       banks.put(new Long JavaDoc(bank.bankNumber),bank);
52    }
53         
54    /**
55     * Makes a transfer between two accounts.<p>
56     *
57     * The source account is debited from the amount wilst the
58     * destination account is credited with the same amount.<p>
59     *
60     * @param asrc the source account
61     * @param adst the destination account
62     * @param amount the amount to tranfer */

63
64    public void transfer (Account asrc, Account adst, double amount) {
65       adst.credit(amount);
66       asrc.debit(amount);
67    }
68
69 }
70
Popular Tags