Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.40 KB | None | 0 0
  1. private fun computeGameResult(myMove: GameOption, opponentMove: GameOption): GameResult {
  2.         if (myMove == opponentMove) return GameResult.TIE
  3.  
  4.         return when (myMove) {
  5.             ROCK -> if (opponentMove == SCISSORS) return WIN else LOSE
  6.             PAPER -> if (opponentMove == ROCK) return WIN else LOSE
  7.             SCISSORS -> if (opponentMove == PAPER) return WIN else LOSE
  8.         }
  9.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement