Created
May 8, 2018 16:20
-
-
Save piperniehaus/94d288d8b8db2c17880b9785e6a4eb03 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
sealed class Pet | |
data class Dog(val name: String, val breed: String, val tricks: Array<String>) : Pet() | |
data class Cat(val name: String, val breed: String) : Pet() | |
data class Bird(val name: String, val breed: String, val words: Array<String>) : Pet() | |
fun playWithPet(pet: Pet):String{ | |
when(pet){ | |
is Dog -> println("You played with a DOG!") | |
is Cat -> println("You played with a CAT!") | |
} | |
return "I am happy because I am playing with pets" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment