Created
November 23, 2019 13:12
-
-
Save kmdsbng/8feef9db47cf65a2d730d527bc4b9eb2 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
interface BooBoo { | |
fun sayBoo(): String | |
} | |
data class Tanon(val char: String) : BooBoo { | |
override fun sayBoo(): String = char | |
} | |
data class Choon(val char: String) : BooBoo { | |
override fun sayBoo(): String = char + "ー" | |
} | |
fun main() { | |
val chars = listOf("ボ", "ジョ", "レ", "ヌ", "ボ") | |
val booBoos : List<BooBoo> = chars.shuffled().withIndex().map { (index, char) -> | |
if (index > 1) { | |
Choon(char) | |
} else { | |
Tanon(char) | |
} | |
} | |
println(booBoos.map {it.sayBoo()}.joinToString("")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment