Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.40 KB | None | 0 0
  1. fun getChoice(input: String?) = when(input) {
  2.    Choices.ROCK.id -> Choices.ROCK.name()
  3.    Choices.PAPER.id -> Choices.PAPER.name()
  4.    Choices.SCISSORS.id -> Choices.SCISSORS.name()
  5.    else -> "BAD CHOICE"
  6. }
  7.  
  8. fun main() {
  9.     val player = Player()
  10.     var input: String
  11.     print("Enter your choice: ")
  12.     input = readline()!!
  13.  
  14.     player.choice = getChoice(input)
  15.     println(player.choice)
  16.  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement