Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Still trying to create a Bank for my BankAccounts

 
Jenny Daniels
Greenhorn
Posts: 5
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! I'm having some difficulty with a practice problem that involves creating a Bank and BankAccount class to be tested later against a tester class. The tester has reference to a single Bank object which 'owns' many BankAccount objects.

Here is my code for the Bank and BankAccount classes.

I am pretty sure my BanAccount code is correct but I am not sure the bank is doing what it's supposed to... any help would be much appreciated. I know Bank is supposed to be set up in a way that the instance methods for the bank class are described as so:

addAccount (int acctNum, double initialDeposit) : void -calls constructor

deposit (int acctNum, double amount): void -calls deposit(..)

withdraw (int acctNum, double amount): void -calls withdraw(..)

getBalance(int acctNum): double -calls getBalance()

suspend/open/closeAccount (int acctNum): void -calls suspend()/open()/close() to change account status

getAccountStatus(int acctNum): String -returns the account's status by calling getStatus()

accountTransactionsString(int acctNum): String -calls transactionsString()

summarizeAllAccounts(): String -returns a summary of the bank's accounts (similar to what I've been trying to describe)
 
Red Smith
Ranch Hand
Posts: 136
1
Netscape Opera Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why have you made the data and the methods of the BankAccount class static?
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello and welcome to the Ranch!

Please TellTheDetails (<- click) when posting a question. Saying that there is something wrong with your code won't help you much, because you should point to a specific part of code that you think is wrong. Once you target problematic part of code you should post it here so we can all take a look and discuss it. Providing a link to your git repository is not such a good idea, since you can delete repository after some time and the post here remains. So for someone who checks the thread later it can be really confusing reading a discussion without knowing anything about the details of the problem you are facing.

As Red Smith pointed out, for start you should change methods not to be static (if you really don't have a good reason to leave them as such, and I think you don't).

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic