Alright ill apreciate some help, so here is the exercise and also what i have done so far. im a little bit lost on how to keep going. 

Problem Description:
1. Create Minimal Account Class for containment in the Bank container.

2. Define a Bank Class to hold Account Objects
    a) Has a data structure and attributes to manage the Accounts
       on the Heap.
    b) A Constructor which creates a Bank of any size at runtime.
    c) Methods to open(add) account object, close(remove) account object,
       show "Account Summary", make a deposit & make a withdrawal
       wrapper methods, add existing account from outside the bank,
       and  other helper methods that would be appropriate.

 3. Write a test program to create a Bank object at runtime, add Account
    objects, verify your Methods, and remove Account objects,

Bank.java

    package javalab2;

    public class Bank
    {

    private Account[] a;
    private int cnt;
    static Bank [] b1;

    public Bank(int n)
    {
    this.a = new Account [n];
    }

    public boolean openAcct(double amt)
    {
        boolean rc = false;

        if (cnt <a.length)
            for (int i=0; i <a.length && !rc; i++)
                if (a[i] ==null)
                {
                    a[i] = new Account (amt);
                    cnt++;
                    rc = true;
                }
        return rc;
    }
    public Account getAcct(int n)
    {
        if ( cnt==0) return null;
                for (int i=0; i <a.length; i++)
                    if (a[i] != null)
                        if (a[i].getID() == n)
                            return new Account (a[i]);
                return null;


    }
    }

Account.java

    package javalab2;

    public class Account
    {
    private int id;
    private double bal;
    private static int nxtID = 99;

    private static int getNextID()
    {
    }

    public Account(double b)
    {
    this.bal += b;
    }
    public Account(Account r)
    {
    }
    public int getID()
    {
     return id;
    }
    public double getBal()
    {
     return bal;
    }
    }//end class Account

Recommended Answers

All 3 Replies

ok...

so, you have code ... now what is the actual question?
preferably, don't give your variables names like
a
give it a meaningfull name, so that the code becomes more clear and readable.

the questions is: based on the exercise: what should i do next, most of the stuff thats on this code, i got it from my professor, i would just like to know what constructors im missing on each class (if not how do I write the ones that are empty) and how do I write the tester class

we're not here to do your homework for you, kid.
And if you'd paid attention in class you should easily be able to do all that yourself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.