Score -- A single score for either technical or artistic merit on a single performance by a single judge.
* Fields: rating (double), judgeName (String)
* Methods
o a two-parameter constructor
o an accessor method for rating
o a mutator method for rating
o an accessor method for judgeName
o a mutator method for judgeName
PerformanceScore -- All ratings of all judges for a single performance.
* Fields: technicalMerit (ArrayList of Score), artisticMerit (ArrayList of Score)
* Methods
o public a no-parameter Constructor that initializes the two fields to empty ArrayLists
o public addScore with three parameters: a char containing an 'a' or 't' indicating that this is either an artistic or technical score, a double containing: the actual score, and a String containing the name of the judge
o public getScores with no parameters that returns a string containing all the scores in the following format:
Technical Scores
judgeName1: score1
judgeName2: score2
etc.
Artistic Scores
judgeName1: score1
judgeName2: score2
etc.
o public technicalMeritRating with no parameters and returns a double which is the average of all the technicalMerit scores omitting the max and min score
o public artisticMeritRating with no parameters and returns a double which is the average of all the artisticMerit scores omitting the max and min score
o private maxRating with one parameter (either the technicalMerit or artisticMerit ArrayList) and returns the maximum rating in the list
o private minRating with one parameter (either the technicalMerit or artisticMerit ArrayList) and returns the minimum rating in the list
Now i have the code for Score:
public class Score { private double rating; private String judgeName; public Score(double rating, String judgeName) { this.rating = rating; this.judgeName = judgeName; } public void getRating() { System.out.println("" + rating); } public void newRating(double newRating) { rating = newRating; } public void getJudgeName() { System.out.println("" + judgeName); } public void newJudge(String newJudge) { judgeName = newJudge; } }
And then I have the beginning code of PerformanceScore:
import java.util.ArrayList; import java.util.Iterator; public class PerformanceScore { private ArrayList<Score> technicalMerit; private ArrayList<Score> artisticMerit; public PerformanceScore() { technicalMerit = new ArrayList<Score>(); artisticMerit = new ArrayList<Score>(); } public void addScore(char letter, double actualScore, String judgeName) { if(letter == 'a') artisticMerit.add(new Score(actualScore, judgeName)); else technicalMerit.add(new Score(actualScore, judgeName)); } public void getScores() { System.out.println("Technical Scores"); for(int i = 0; i < technicalMerit.size(); i++) System.out.println( "" + artisticMerit.get(i) ); } System.out.println("Artistic Scores"); for(int i = 0; i < artisticMerit.size(); i++) System.out.println( "" + artisticMerit.get( i ) ); } }
I was wondering if anyone could tell me if I'm using the right Variables in things like the addScore method and how I can print out the scores in the style shown at the beginning of this post.