/** Creates a new GradeManager. */ public GradeManager() { // Create a new HashMap of the grades this.allGrades = new HashMap<LetterGrade, Integer>(); // Add in all grades and set the occurance to 0 for (LetterGrade gl : LetterGrade.values()) { allGrades.put(gl, 0); } }
/** * Returns a string representation of the histogram of the grades. * * @return a string representation of the histogram of the grades. */ public String getHistString() { StringBuffer sb = new StringBuffer(); for (LetterGrade gl : LetterGrade.values()) { sb.append(gl + ":"); for (int i = 0; i < this.allGrades.get(gl); i++) { sb.append("*"); } sb.append("\n"); } return sb.toString(); }