Forums Register Login

cant find methods

+Pie Number of slices to send: Send
I have been stuck on this for days! I am trying to call some methods once a button is pressed but i keep getting errors that the methods cant be found, I have tried a lot of different stuff but nothing is working. Here is the main class with the methods as well as the GUI class (where the problem of calling methods from the main class is happening.) and the last one is the Test class to run everything.


GUI


Test class


any help here would be SERIOUSLY appreciated. thanks in advance.
+Pie Number of slices to send: Send
What error are you getting?
+Pie Number of slices to send: Send
cannot find symbol - method setScores(double[])

i used to have Judging.setScores(scores) - which im pretty sure is more accurate - but i kept trying more and more random stuff out of frustration.
1
+Pie Number of slices to send: Send
Your method setScores(double[] score) belongs to the Judging class. You are trying to invoke it from the JudgingGUI class.

Hint: Can you invoke a method without having a reference to the object which is the owner of the method?

Imagine a User class with a method getMailID() which returns the mail ID of that user.
Now imagine two users Andrew and Maneesh
Now imagine some class invoking the method getMailID() like the way you have coded.
Would the JVM know whose mail ID you are asking for? Andrew's or Maneesh's?
+Pie Number of slices to send: Send
so you are saying it would need to be something like

?
+Pie Number of slices to send: Send
 

andrew cassato wrote:so you are saying it would need to be something like

?



Then you will have to make your method static in the class. You can try the same by creating any instance of the Judging class and use that
1
+Pie Number of slices to send: Send
No. What you have there is a static method
What you need to do is obtain an instance of the Judging class and then invoke the setScores on it.

Judging judge=new Judging();
judge.setScore(scores);


Just remember, whenever you invoke setScores() you would want to invoke it on the same instance. So it the judge should be stored as a class variable in your JudgingGUI
+Pie Number of slices to send: Send
 

Maneesh Godbole wrote:No. What you have there is a static method
What you need to do is obtain an instance of the Judging class and then invoke the setScores on it.

Judging judge=new Judging();
judge.setScore(scores);


Just remember, whenever you invoke setScores() you would want to invoke it on the same instance. So it the judge should be stored as a class variable in your JudgingGUI



this is obviously not that clear to me, I'm not 100% sure where to put
Judging judge=new Judging();
I tried a couple places but i get an error "cannot find symbol - variable judge" in the same place where i was getting errors before
1
+Pie Number of slices to send: Send
 

andrew cassato wrote:

Maneesh Godbole wrote:No. What you have there is a static method
What you need to do is obtain an instance of the Judging class and then invoke the setScores on it.

Judging judge=new Judging();
judge.setScore(scores);


Just remember, whenever you invoke setScores() you would want to invoke it on the same instance. So it the judge should be stored as a class variable in your JudgingGUI



this is obviously not that clear to me, I'm not 100% sure where to put
Judging judge=new Judging();
I tried a couple places but i get an error "cannot find symbol - variable judge" in the same place where i was getting errors before



Sample -

+Pie Number of slices to send: Send
thanks that did the trick, now to solving the rest!

thanks.
I've never won anything before. Not even a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1459 times.
Similar Threads
third attempt at solving this
i cant figure out how to use these methods
more problems calling methods
Converting threadgroup to executorservice
losing data
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:28:43.