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
creativeguitar 0 Newbie Poster
stultuske 1,116 Posting Maven Featured Poster
creativeguitar 0 Newbie Poster
jwenting 1,889 duckman Team Colleague
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.