Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

losing data

 
andrew cassato
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15284
39
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
andrew cassato
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12125
30
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
andrew cassato
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 48961
60
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12125
30
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic