This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes losing data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "losing data" Watch "losing data" New topic
Author

losing data

andrew cassato
Ranch Hand

Joined: Nov 14, 2010
Posts: 37
I cant figure out why i am losing the data here, when i press compute scores i get 0.0. the array score takes in the data just fine but i cant figure out where it goes at the end... error is at line 88 in the GUI class
JUDGING

GUI

TEST

Thanks for taking a look for me
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Okay, that's a lot of code; so to be honest, I haven't looked at it.

But my suggestion is to add lots of println statements at various points, to determine what the values are at each stage.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Look at the actionPerformed method of your JudgeListener; especially lines 73 - 89.

In line 74, you declare a variable called result which you set to 0. In line 88, you are printing the value of that variable. But nowhere in between lines 74 and 88 are you assigning any other value to result, so it will still be 0 when the program reaches line 88, and it will always print 0.

Probably you meant to write this in line 86:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
andrew cassato
Ranch Hand

Joined: Nov 14, 2010
Posts: 37
tried
result = judge.getResult();
but still wont work. i have used the debugger to make sure the data is ok up until this last part where its gone because i am not storing it after getResult (i think) - but i am not sure how to do that.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11170
    
  16

when you make these calls:



you are not saving what comes back. Therefore, the values are lost. As Jesper says, you need to save these values, and then print the variable where you saved them.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
andrew cassato
Ranch Hand

Joined: Nov 14, 2010
Posts: 37
i understand i need to save them, that makes perfect sense, i just dont know where to do so...

when i have the contestants final score come up does that belong in a JTextField or JLabel?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
You can put the results anywhere you want; if you want a Component which the user can't alter, setting the text on a JLabel sounds a good idea.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11170
    
  16

andrew cassato wrote:i understand i need to save them, that makes perfect sense, i just dont know where to do so...

In your actionPerformed() method of the JudgeListener class, you have a variable called "result". I would suggest you use this to store the result.

result = judge.getResult();

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: losing data
 
Similar Threads
i cant figure out how to use these methods
more problems calling methods
cant find methods
third attempt at solving this
Converting threadgroup to executorservice