Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Menu/Kotlin/menu.kotlin
Normal file
25
Task/Menu/Kotlin/menu.kotlin
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// version 1.1.2
|
||||
|
||||
fun menu(list: List<String>): String {
|
||||
if (list.isEmpty()) return ""
|
||||
val n = list.size
|
||||
while (true) {
|
||||
println("\n M E N U\n")
|
||||
for (i in 0 until n) println("${i + 1}: ${list[i]}")
|
||||
print("\nEnter your choice 1 - $n : ")
|
||||
val index = readLine()!!.toIntOrNull()
|
||||
if (index == null || index !in 1..n) continue
|
||||
return list[index - 1]
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val list = listOf(
|
||||
"fee fie",
|
||||
"huff and puff",
|
||||
"mirror mirror",
|
||||
"tick tock"
|
||||
)
|
||||
val choice = menu(list)
|
||||
println("\nYou chose : $choice")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue