Skip to content

Instantly share code, notes, and snippets.

@pandulapeter
Created February 20, 2018 13:37
Show Gist options
  • Save pandulapeter/484c55d09c30abc5297f72e58fb4e457 to your computer and use it in GitHub Desktop.
Save pandulapeter/484c55d09c30abc5297f72e58fb4e457 to your computer and use it in GitHub Desktop.
Sealed class
sealed class Screen {
abstract val screenName: String
object Menu : Screen() {
override val screenName = "Menu screen"
}
object Leaderboard : Screen() {
override val screenName = "Leaderboard screen"
}
sealed class Game(var score: Int) : Screen() {
class Level1(score: Int) : Game(score) {
override val screenName = "Level 1"
}
class Level2(score: Int) : Game(score) {
override val screenName = "Level 2"
}
class Level3(score: Int) : Game(score) {
override val screenName = "Level 3"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment