Skip to content

Instantly share code, notes, and snippets.

@travisdachi
Created August 3, 2016 22:51
Show Gist options
  • Save travisdachi/ba302a8028df85427d90e60a30be3d0e to your computer and use it in GitHub Desktop.
Save travisdachi/ba302a8028df85427d90e60a30be3d0e to your computer and use it in GitHub Desktop.
class SuGrader(val satisfy: Int = 60) : Grader {
init {
if (satisfy < 0 || satisfy > 100)
throw IllegalArgumentException("A satisfy $satisfy is out of score range of 0-100")
}
override fun grade(score: Int) = when (score) {
in satisfy..100 -> "S"
in 0 until satisfy -> "U"
else -> "???"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment