wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Just Can't figure it out and it's due today Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Just Can Watch "Just Can New topic
Author

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

Chris Burkovich
Greenhorn

Joined: Oct 23, 2009
Posts: 11
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

Joined: Oct 02, 2003
Posts: 11153
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Chris Burkovich
Greenhorn

Joined: Oct 23, 2009
Posts: 11
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

Joined: Jan 28, 2003
Posts: 4165
    
  21

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.


Steve
Chris Burkovich
Greenhorn

Joined: Oct 23, 2009
Posts: 11
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

Joined: Oct 23, 2009
Posts: 11
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

Joined: Oct 23, 2009
Posts: 11
the final version looks like this


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Just Can't figure it out and it's due today
 
Similar Threads
need help urgent please
Bank program class or switch problem
Need help with username and password validation
toString method in vector.
Bank Account Program Help