• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Just Can't figure it out and it's due today

 
Chris Burkovich
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in line 60 is the method to call up the acct1 class but when I run the compiler and exicute line 40 doesn't do what I want. if I freeze the method and make it an empty shell it works without error but Line 40 only gives a zero. What am I doing wrong.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12203
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't even see how this would compile. The ONLY place where you use the variable "acctNumber" is in line 40 - you never declare it or initialize it.

Further, on casual inspection, i would think you'd get an infinite loop... Your getAccountNumber method seems to call itself I think:



also, it's either named wrong or declared wrong. generally, something called "getXXX" is going to return a value - i.e. the thing you want to get. Your method is declared as 'void', which means it returns nothing.
 
Chris Burkovich
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:I don't even see how this would compile. The ONLY place where you use the variable "acctNumber" is in line 40 - you never declare it or initialize it.

Further, on casual inspection, i would think you'd get an infinite loop... Your getAccountNumber method seems to call itself I think:



also, it's either named wrong or declared wrong. generally, something called "getXXX" is going to return a value - i.e. the thing you want to get. Your method is declared as 'void', which means it returns nothing.

your rite I changed

to

what I also did prior was have the class Account open but I still can not get line 40 to work rite
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this the line 40 you are talking about?



If so, then the acctNumber you are printing is the one defined in the ATMSimulation method:


Which you declare but never set. So it will use the default value, which is 0.
 
Chris Burkovich
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:Is this the line 40 you are talking about?




yes but from the class Account

but by changing line 40 to

I get the result I want but buy pass the method getAcctNumber() all together and my professor will have an issue with that
just can't figure it out
 
Chris Burkovich
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
buy removing the method getAcctNumber() all together
and in the helper class Account adding a

I get what I want but thanks to fred and steve for pointing things out better
 
Chris Burkovich
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the final version looks like this


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic