Last active
August 10, 2018 10:51
-
-
Save ataulm/5686a3841da44cb0e054bfe0ce5b75ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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