Package model
Class Grader
java.lang.Object
model.Grader
Helper class for calculating the score and grading a game. Should be used statically
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intThe initial score before calculationsprivate static final doublemin sec clamp uses this multiplier for the scoreprivate static final doublelargest possible time used in calculationsprivate static final doublemax sec clamp uses this multiplier for the scoreprivate static final doubleSmallest possible time used in calculationsprivate static final intThe minimum score that can be returnedprivate static final intthis times the number of tries is subtracted from the initial score -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcalculatePoints(int tries, long millis) Calculates the score based on the number of tries and the time (s) uses line equation y = mx + b where y is the score multiplier, x is the time in seconds m = (MIN_SCORE_MULT - MAX_SCORE_MULT) / (MAX_SEC_CLAMP - MIN_SEC_CLAMP)static StringscoreGrader(int points, ModeType modeType) gives grades for points.
-
Field Details
-
INITIAL_SCORE
private static final int INITIAL_SCOREThe initial score before calculations- See Also:
-
MINIMUM_SCORE
private static final int MINIMUM_SCOREThe minimum score that can be returned- See Also:
-
TRIES_INCREMENT
private static final int TRIES_INCREMENTthis times the number of tries is subtracted from the initial score- See Also:
-
MIN_SEC_CLAMP
private static final double MIN_SEC_CLAMPSmallest possible time used in calculations- See Also:
-
MAX_SEC_CLAMP
private static final double MAX_SEC_CLAMPlargest possible time used in calculations- See Also:
-
MIN_SCORE_MULT
private static final double MIN_SCORE_MULTmax sec clamp uses this multiplier for the score- See Also:
-
MAX_SCORE_MULT
private static final double MAX_SCORE_MULTmin sec clamp uses this multiplier for the score- See Also:
-
-
Constructor Details
-
Grader
public Grader()
-
-
Method Details
-
calculatePoints
public static int calculatePoints(int tries, long millis) Calculates the score based on the number of tries and the time (s) uses line equation y = mx + b where y is the score multiplier, x is the time in seconds m = (MIN_SCORE_MULT - MAX_SCORE_MULT) / (MAX_SEC_CLAMP - MIN_SEC_CLAMP)- Parameters:
tries- number of triesmillis- time in milliseconds since last correct guess- Returns:
- the score
-
scoreGrader
gives grades for points. returns maximum 4 stars. ⭐⭐⭐⭐- Parameters:
points- pointsmodeType- difficulty- Returns:
- grade
-