posted on Apr, 1 2009 @ 11:35 PM
In my Computer Science class today, we were given a programming assignment that we could complete by Friday at Midnight for extra credit. I am pretty
decent in the language, as far as basics, and using for and while loops, but I am struggling with Array Lists for some reason. I was wondering if
there was anyone on here that knows enough about Java to assist me. Here are the terms of the program:
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
Competitor -- Information about one competitor in the gymnastics event
* Fields: competitorName and country (both Strings)
* Methods
o a two-parameter constructor (strings for name and country)
o mutator methods for both fields
o accessor methods for both fields.
Performance -- The scores and competitor information for one performance in one event
* fields: scores (PerformanceScore) and competitor (Competitor)
* methods
o a one-parameter constructor (the competitor): The constructor should initialize the competitor field to the parameter and initialized the
scores field to an empty PerformanceScore.
o public getCompetitor: an accessor method for the competitor field (returns a reference to a Competitor object)
o public listScores: no parameters; displays the result of scores.getScores() on the terminal window
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 (this just calls scores.addScore allowing us to add scores from
the Performance class
o public performanceRating: no parameters; returns the average of the technicalMeritRating and the artisticMeritRating
Event -- Representing all Performances in one event in the competition
* fields: performances (ArrayList of Performance), eventName (a String)
* methods
o a one-parameter (a String) constructor that initializes the eventName to the parameter and initializes performances to an empty list
o public addPerformance with one parameter (a Performance object)
o public winner returns a string containing the performanceRating, the name of the winner, and the country of the winner in the following
format
Winner: name, country. Score: score
o (Note: We will eventually provide a factory method that randomly generates a complete Performance object that can be passed to
addPerformance. Until this factory method is available, you'll have to create the Objects by individually requiring considerable data entry for each
Performance object.)