• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

losing data

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 11343
Mac Safari Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 79153
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13089
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();

 
reply
    Bookmark Topic Watch Topic
  • New Topic