• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

more problems calling 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 am getting an error when I try to pass an array (score) to a method in another class. i am not sure i have them set up right - I am trying to have the contestant's score calculated and displayed when i press the calculate scores button but get the error
getScores() in Judging cannot be applied to (double[])
here is all the code. error is on line 78 of the GUI class
Judging class

GUI class

Test class


i dream of the day this project is done... thanks in advance.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You are calling a method called getScores, have one parameter of type double[]. There is no such method in the Judging class. Same for getResult. What are you trying to do. Your methods have no parameter, but they return something. So you are expected to call them like :


But still, I don't understand why you are calling these methods.

(it would help next time to post the full stack trace of your compilation error)
 
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
im trying to pass this array of scores thru these other methods to get the final score and display it in the GUI... am i on the right track?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You're still passing an array to the getScores() method, that won't work. Look at the method :

No parameter, a returned value of type double[].

Now, can you tell me in plain English what you are trying to achieve here ? Try to put some comment next to the method calls.

Why do I want you to explain the method calls ? Because the setScores method set the scores you have passed it, and getScores get those scores. It doesn't make sense here to call them like this.
 
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'm actually not even sure what the setScores and getScores methods do, I just have the outline of the program with those methods:
_______________________________________________
| Judging |
|_______________________________________________|
| - int n //number of judges |
| - double [] scores //scores of n judges |
| - double result;//the score from judges |
|______________________________________________ |
| + Judging(int) |
| + setScores(double []) :void |
| + inputScores() :void |
| + calculateScore() : void |
| + getScores(): double [] |
| + getResult(): double |
|_______________________________________________|

using the UML i know these methods are supposed to be used i just dont really know how... To me it seems like I would just have to send the array of scores to calculateScores and have it return the finalScore but then I dont know what the other stuff is for.
 
Marshal
Posts: 80775
489
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That UML tells you the Judging class has three private (= "-") fields, n, scores and result; it also tells you what types they are.
It tells you the class has a public (= "+") constructor taking an int as parameter, a setScores method taking double[] and returning void, an inputScore() method with no parameters and void return type and three other methods which I am sure you can now work out from the diagram.
There ought to be a javadoc document made from that class; it will be in html format and you open it with a web browser. That should tell you what the constructor and 4 methods do.
reply
    Bookmark Topic Watch Topic
  • New Topic