AlgoMaster Logo
AlgoMasterExtend a Grading Policyeasy

Extend a Grading Policy

easy

Complete one new implementation in an existing Open–Closed design.

ScoreReporter already works with the GradingPolicy interface. Its pass/fail and letter-grade policies are complete, and the reporter can use either one without knowing its rules. The reporter already references a third policy, HonorsPolicy, but that class has intentionally been left for you to implement.

Implement the missing honors behavior:

  • A score of 90 or more returns "HIGH HONORS".
  • A score from 75 through 89 returns "HONORS".
  • A score below 75 returns "STANDARD".

Keep the existing design intact. Do not add an honors condition to ScoreReporter, and do not modify PassFailPolicy or LetterGradePolicy.

The reporter provides these operations:

  • hasPolicy(name) reports whether a policy is registered.
  • policyCount() returns the number of registered policies.
  • labelFor(policyName, score) returns the selected policy's label, or "UNKNOWN POLICY" when the name is not registered.
  • report(policyName, student, score) returns "<student>: <label>", or "UNKNOWN POLICY" for an unknown policy.

Assume scores are between 0 and 100.

How the design is graded

needs 7/10 to pass
  • New implementation

    Full marks when HonorsPolicy implements the existing GradingPolicy contract and owns all honors thresholds. Lose points heavily when honors logic is placed in ScoreReporter or either existing policy.

  • Stable client

    Full marks when ScoreReporter continues to look up a GradingPolicy and call labelFor without checking a concrete type or policy name. Lose points for an honors branch, type check, or switch in labelFor or report.

  • Behavior

    Full marks when scores of at least 90 return HIGH HONORS, scores from 75 through 89 return HONORS, lower scores return STANDARD, and all existing policies and unknown-policy behavior remain unchanged. Lose points for boundary errors, changed output text, or printed output.

Passing every test is not enough on its own. A submission is accepted only when the design also clears the bar.

Hints

Loading...
CallReturns
new ScoreReporter()null
policyCount()3
hasPolicy("honors")true
labelFor("honors", 95)"HIGH HONORS"
labelFor("honors", 80)"HONORS"
report("honors", "Mina", 70)"Mina: STANDARD"

The new HonorsPolicy supplies all three labels through the existing policy interface.

Run checks these cases. Submit also runs a larger hidden set.