Package model

Class Grader

java.lang.Object
model.Grader

public class Grader extends Object
Helper class for calculating the score and grading a game. Should be used statically
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
    The initial score before calculations
    private static final double
    min sec clamp uses this multiplier for the score
    private static final double
    largest possible time used in calculations
    private static final double
    max sec clamp uses this multiplier for the score
    private static final double
    Smallest possible time used in calculations
    private static final int
    The minimum score that can be returned
    private static final int
    this times the number of tries is subtracted from the initial score
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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)
    static String
    scoreGrader(int points, ModeType modeType)
    gives grades for points.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • INITIAL_SCORE

      private static final int INITIAL_SCORE
      The initial score before calculations
      See Also:
    • MINIMUM_SCORE

      private static final int MINIMUM_SCORE
      The minimum score that can be returned
      See Also:
    • TRIES_INCREMENT

      private static final int TRIES_INCREMENT
      this times the number of tries is subtracted from the initial score
      See Also:
    • MIN_SEC_CLAMP

      private static final double MIN_SEC_CLAMP
      Smallest possible time used in calculations
      See Also:
    • MAX_SEC_CLAMP

      private static final double MAX_SEC_CLAMP
      largest possible time used in calculations
      See Also:
    • MIN_SCORE_MULT

      private static final double MIN_SCORE_MULT
      max sec clamp uses this multiplier for the score
      See Also:
    • MAX_SCORE_MULT

      private static final double MAX_SCORE_MULT
      min 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 tries
      millis - time in milliseconds since last correct guess
      Returns:
      the score
    • scoreGrader

      public static String scoreGrader(int points, ModeType modeType)
      gives grades for points. returns maximum 4 stars. ⭐⭐⭐⭐
      Parameters:
      points - points
      modeType - difficulty
      Returns:
      grade