• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

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

 
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.
 
lowercase baba
Posts: 12834
52
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
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • 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


 
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic