• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

cant find methods

 
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 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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What error are you getting?
 
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
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.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
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
so you are saying it would need to be something like

?
 
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
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

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
 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • 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:

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 -

 
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
thanks that did the trick, now to solving the rest!

thanks.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic