• 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

i cant figure out how to use these 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 no idea what i am doing wrong here. I had the method calculateScore working on its own but when i made the program into a GUI it stopped. it calculates a contestants score (which is an array of doubles) but it gives me an error "calculateScore in Judging cannot be applied to (double[])" and i cant figure out why!

The error is on line 79 of the GUI class

Here are the 3 classes

JUDGING

GUI

TEST


Thanks in advance for helping with my HW that was due 8 days ago
 
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 still haven't quite understood how to call methods It's ok. Look at your method signature :

What does it tell you ?
1. It doesn't return any value
2. It has no parameter

Your are calling it this way :

The compile error tells you that "calculateScore in Judging cannot be applied to (double[])", and you can see why. You are trying to pass an array of double to a method which has no parameters.

It shouldn't be working in a non-gui application either.
 
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
in the ULM he showed us it has this method as:
+ calculateScore() : void
so i dont know what i am supposed to do at all, what would you do?
 
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
Do you have any documentation with the UML, or only the UML ?
 
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
everything is in here:
http://140.192.1.66/ggordon/courses/212/212/homework.dir/program3.html
 
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
It says it all :

You convert your getData method from Program 1 to the inputScores method. However, it is not needed in this program as the data is read in via the GUI. The method setScores would look like:


So you have to pass the scores which were input by the judges to the setScores method.

The only change in calculateScore is that it doesn't return the actual score but assigns to it to the member of result. The user gets the value of result by calling the method of getResult, which just has one line of code.


After calling setScores, you have to call calculateScore. The result can be retrieved by calling getResult.

So, your logic should looki like :

After that, you have to set the result in the textfield.
 
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 am still getting the error "calculateScore() in Judging cannot be applied to (double[])"
 
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
My bad. It should be "judge.calculateScore();".

But can't you still figure it out by yourself despite my previous explanation ? You have to understand how methods are used. It is very important. I'm very concerned that even if you finish your assignment, you still won't understand how to call methods.
 
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 thought you had to have score in parenthesis because thats what you are sending to the method... how would it know to pass the array thru without putting in that line of code?
 
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 set the scores by calling setScores. It stores the scores in a private instance variable (this.score = score ). calculateScore is using that variable So you shouldn't have the following in calculateScore :

You have to use Judging's "score" variable instead.
 
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
OK i got rid of those 2 lines of code but still having problems... do i even need to have the lines:

and


When i try to just have it print the result it just shows 0.0 even tho when i went thru it with the debugger all the elements of the array were valid, where is the disconnect?

also, when i try to have the JLabel display the result like so:

it tells me "cannot find symbol - constructor JLabel(double)" so how do you have it display a variable?

my brain is fried
 
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

andrew cassato wrote:when i try to have the JLabel display the result like so:

it tells me "cannot find symbol - constructor JLabel(double)" so how do you have it display a variable?

my brain is fried



Llok at the documentation here

There is no constructor which takes double as argument while creating JLabel. and you are passing in constructor a double value (i.e. result).
 
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
I think you have to go through your requirements once again. I'm not going to give you a full solution of your assignment. The assignement says :


actionPerformed :
If all of the scores are within range, it will put the array of scores in Judging by calling setScores. It will then call the method calculateScores of Judging to compute the score. It will then call the method of judging getScores to get the score. It will put the attained score into the textbox for the score.


You can't get more explicit than that. This is were getScores is going to be called. And once again, why are you passing an array to getScores...

it tells me "cannot find symbol - constructor JLabel(double)" so how do you have it display a variable?


1. The assignement assumes that JudgingGUI implements ActionListener. The actionPerformed method should be in JudgingGUI, not in a separate class.
2. Why are you making a new label ?
3. You still can't read a method signature. Look at the API for JLabel. Do you see any constructor with an double[] as a parameter ?
 
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
ok thanks for all your help
 
Get me the mayor's office! I need to tell him about this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic