Skip to content

Instantly share code, notes, and snippets.

@ataulm
Last active August 10, 2018 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ataulm/5686a3841da44cb0e054bfe0ce5b75ea to your computer and use it in GitHub Desktop.
Save ataulm/5686a3841da44cb0e054bfe0ce5b75ea to your computer and use it in GitHub Desktop.
data class IceCream(val scoops: Int)
data class ScoopResult(val iceCream: IceCream?, val iceCreamTub: IceCreamTub)
class ScoopAction {
fun scoop(iceCreamTub: IceCreamTub): ScoopResult {
val scoops = iceCreamTub.remainingScoops
if (scoops == 0) {
return ScoopResult(null, iceCreamTub)
}
return ScoopResult(IceCream(1), IceCreamTub(scoops - 1))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment