• Post Reply Bookmark Topic Watch Topic
  • New Topic

Transfer Function on the verge of working  RSS feed

 
Brian O'Connor
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, after days of working through this code i believe i have nearly have it right except the transfer amount goes to another account instead of the one selected, i have spent hours trying different methods of getting it to transfer the amount to the designated account by the user. This is what i have so far...







if i add another String to the balance class String balance = atmData.getBalance1(); the correct output comes for that account that has had money transferred to it but it is not right for the other accounts. How do i get the correct balance to show for accounts that have not had their money deducted or increased and vice versa for the accounts that have had money transferred to them?
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You aren't programming in an Object Oriented way. Your String[][] should be replace by something like List<Account>. In which Account holds the information about the user, it's balance etc... Also you shouldn't make everything static. Look up what static means and explain to yourself why something should be static. The Reader on line 51 is never closed. Always close your resources properly as it may cause unexpected behaviour if you don't (check out the try with resources from Java 7).

I think that if you make these changes you'll find the error you're looking for.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He has been told you use a String[][]. I think I agree with you, Wouter, that was really bad advice he has been given.
 
Brian O'Connor
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know that it has been designed pretty bad =(, but i know of somebody using a combo box for users to select which account they want to transfer money to and it works perfectly. I assumed it would be very similar to what i am trying to do with a textfield. Would using String[][] mean i would have not make a new class? sorry but I've only just started using java.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you ought to be using an Account class or similar instead of a String[][]. I have told you my opinion several times.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!