```
/**
* Question #36784
*
* Task:
* Consider a class ScienceFairProjectRating that will be used to help
* judge a science fair project. attributes for the new class are:
* The name of the project
* A unique identification string for the project
* The name of the person
* A rating for the creative ability (max. 30)
* A rating for the scientific thought (max. 30)
* A rating for thoroughness (max. 15)
* A rating for technical skills (max. 15)
* A rating for clarity (max. 10)
* It will have methods to
* Get the number of judges
* Get all the ratings for a particular project
* Return the total of the rating for a particular project
* Return the maximum total rating possible
* Return a string showing a projects rating in a format suitable for
* display
*/
public class ScienceFairProjectRating {
private static final int MAX_CREATIVE_ABILITY = 30;
private static final int MAX_SCIENTIFIC_THOUGHT = 30;
private static final int MAX_THOROUGHNESS = 15;
private static final int MAX_TECHNICAL_SKILLS = 15;
private static final int MAX_CLARITY = 10;
private static int ID = 0;
private int id;
private String authorName;
private String projectName;
private int creativeAbilityRating;
private int scientificThoughtRating;
private int thoroughnessRating;
private int technicalSkillsRating;
private int clarityRating;
/**
*
* @param authorName
* @param projectName
*/
public ScienceFairProjectRating(String authorName, String projectName) {
this.authorName = authorName;
this.projectName = projectName;
id = ++ID;
}
/**
* @return the total of the rating for a particular project
*/
public int getTotalRating() {
int result = creativeAbilityRating;
result += scientificThoughtRating;
result += thoroughnessRating;
result += technicalSkillsRating;
result += clarityRating;
return result;
}
/**
* @return the maximum total rating possible
*/
public int getMaxPossibleRating() {
int result = MAX_CREATIVE_ABILITY;
result += MAX_SCIENTIFIC_THOUGHT;
result += MAX_THOROUGHNESS;
result += MAX_TECHNICAL_SKILLS;
result += MAX_CLARITY;
return result;
}
/**
* @return all the ratings for a particular project
*/
public String[] getAllTheRatings() {
return new String[] {
String.format("%s=%d", "creative ability", creativeAbilityRating),
String.format("%s=%d", "scientific thought", scientificThoughtRating),
String.format("%s=%d", "thoroughness", thoroughnessRating),
String.format("%s=%d", "technical skills", technicalSkillsRating),
String.format("%s=%d", "clarity", clarityRating)
};
}
/**
* @return a string showing a projects rating in a format suitable for
* display
*/
public String getReadableProjectRating() {
String result = String.format(
"A rating for the creative ability (max. %d): %d\n",
MAX_CREATIVE_ABILITY, creativeAbilityRating);
result += String.format(
"A rating for the scientific thought (max. %d): %d\n",
MAX_SCIENTIFIC_THOUGHT, scientificThoughtRating);
result += String.format(
"A rating for thoroughness (max. %d): %d\n",
MAX_THOROUGHNESS, thoroughnessRating);
result += String.format(
"A rating for technical skills (max. %d): %d\n",
MAX_TECHNICAL_SKILLS, technicalSkillsRating);
result += String.format(
"A rating for clarity (max. %d): %d\n",
MAX_CLARITY, clarityRating);
return result;
}
/**
* Get the number of judges
*
* @return number of judges
*/
public int getJudgesNumber() {
return 0; // what data is needed to calculate it?
}
public int getCreativeAbilityRating() {
return creativeAbilityRating;
}
public void setCreativeAbilityRating(int creativeAbilityRating) {
this.creativeAbilityRating = (creativeAbilityRating > MAX_CREATIVE_ABILITY) ? MAX_CREATIVE_ABILITY : creativeAbilityRating;
}
public int getScientificThoughtRating() {
return scientificThoughtRating;
}
public void setScientificThoughtRating(int scientificThoughtRating) {
this.scientificThoughtRating = (scientificThoughtRating > MAX_SCIENTIFIC_THOUGHT) ? MAX_SCIENTIFIC_THOUGHT : scientificThoughtRating;
}
public int getThoroughnessRating() {
return thoroughnessRating;
}
public void setThoroughnessRating(int thoroughnessRating) {
this.thoroughnessRating = (thoroughnessRating > MAX_THOROUGHNESS) ? MAX_THOROUGHNESS : thoroughnessRating;
}
public int getTechnicalSkillsRating() {
return technicalSkillsRating;
}
public void setTechnicalSkillsRating(int technicalSkillsRating) {
this.technicalSkillsRating = (technicalSkillsRating > MAX_TECHNICAL_SKILLS) ? MAX_TECHNICAL_SKILLS : technicalSkillsRating;
}
public int getClarityRating() {
return clarityRating;
}
public void setClarityRating(int clarityRating) {
this.clarityRating = (clarityRating > MAX_CLARITY) ? MAX_CLARITY : clarityRating;
}
public String getProjectName() {
return projectName;
}
public int getId() {
return id;
}
public String getAuthorName() {
return authorName;
}
}