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!
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.
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.
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.
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 :
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 ?