package curve; import java.util.*; import gradebook.*; import items.*; import people.*; /** * The Statistics class performs different math operations on the Scores of a certain Section. * * Derived from the requirements documentation regarding statistics; */ public abstract class Statistics { /** * Determines the maximum RawScore in the collection. Used in Spest. * @param collection Collection to determine the max RawScore * @return RawScore maximum raw score */ private Double max(List collection) { return maxHelper(collection, collection.get(0)); } private Double maxHelper(List collection, Double given) { if(collection.size() == 0) { return given; } else { if(given > collection.get(collection.size() - 1)) { return maxHelper(collection.subList(0, collection.size() - 1), given); } else { return maxHelper(collection.subList(0, collection.size() - 1), collection.get(0)); } } } /** * Determines the minimum RawScore in the collection. Used in Spest. * @param collection Collection to determine the min RawScore * @return RawScore minimum raw score */ private Double min(List collection) { return minHelper(collection, collection.get(0)); } private Double minHelper(List collection, Double given) { if(collection.size() == 0) { return given; } else { if(given < collection.get(collection.size() - 1)) { return minHelper(collection.subList(0, collection.size() - 1), given); } else { return minHelper(collection.subList(0, collection.size() - 1), collection.get(0)); } } } /** * Returns an List of RawScores based on Assignment and Sections. Used in Spest. * @param Assignment assignment of interest * @return List rawscores of all the students for this assignment */ private List getScores(Assignment assignment) { List toReturn = new ArrayList(); for(Section section : sections) { for(Student student : section.students) { toReturn.add(section.scores.getRawScore(student, assignment)); } } return toReturn; } /** * Context Section to apply these operations to. */ Collection
sections; /** * Calculates the average Score for the Assignment in the Section. * @param assignment assignment you wish to calculate the average for * @return Double representing the average *
	 post:
	 	return =< max(getScores(assignment) && return >= min(getScores(assignment);
	 */
	Double average(Assignment assignment) {
	    Double return_ = 0.0;
	    boolean b;

	    // Uncomment the next line to see javac error messages.
	    // b = return_ <= max(getScores(assignment) && return_ >= min(getScores(assignment); 
	    return 0.0;
	}

        /* SPEST ISSUES:
	   The checker correctly identifies the erroneous operator '=<' at line
	   99.  The error message for that is pretty clean:

no viable alternative at input '=' at line: 99 at character: 10

	   After fixing that, some of the checker messages are harder to
	   understand:

found: ';' but was expecting: RPAREN at line: 99 at character: 77
line 113:62 mismatched character '<' expecting set null
line 113:65 mismatched character 'a' expecting set null
   Invalid invocation: getScores(antlr.TestGenerator$arguments_return@7fc8a3e1) at line: 99  at character: 17
   Invalid id: min at line: 99  at character: 52
   Expected type: null, but found: boolean at line: 99 character: 40
   Invalid invocation: max(antlr.TestGenerator$arguments_return@4d7f4a51) at line: 99  at character: 13

	  The javac messages are also pretty jumbled for code like this, but as
	  noted in comments for other teams' specs, there seem to be extra
	  messages from Spest that might be removed in cases like this.

	 */
}