It looks like you're using an Ad Blocker.

Please white-list or disable AboveTopSecret.com in your ad-blocking tool.

Thank you.

 

Some features of ATS will be disabled while you continue to use an ad-blocker.

 

Java Programming Help

page: 1
0

log in

join
share:

posted on Apr, 1 2009 @ 11:35 PM
link   
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.)



posted on Apr, 2 2009 @ 12:39 AM
link   
I've got the score class done here:


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;
]
]

Everything there seems to work fine.The next post will be what I've done so far with the Performance Score class.



posted on Apr, 2 2009 @ 12:41 AM
link   
import java.util.ArrayList;

public class PerformanceScore
[

private ArrayList technicalMerit;
private ArrayList artisticMerit;


public PerformanceScore()
[

technicalMerit = new ArrayList();
artisticMerit = new ArrayList();
]

public void addScore(char letter, double actualScore, String judgeName)
[
if(letter = 'a') artisticMerit.add(rating);
if(letter = 't') technicalMerit.add(rating);

]

public void getScores()
[
System.out.println("Technical Scores");
for (Score judgeName : technicalMerit)
[
System.out.println(judgeName);
]
System.out.println("Artistic Scores");
for (Score rating : artisticMerit)
[
System.out.println(rating);
]


]


]


This is where I'm having problems. I'm not sure how to make the Char variable make it decide whether it is artistic (a) or technical (t). I'm sure more of this code isn't quite right, but I'm not sure what that would be which is why I'm here asking.



new topics
 
0

log in

join