# Git 學習 * https://learngitbranching.js.org/ # Kotlin * Tools -> Kotlin -> Kotlin REPL * REPL (Read-Eval-Print-Look) * 如果遇到問題可以改這裡: * `Run -> Edit Configurations... -> Edit configuration templates... -> Java Scratch -> Shorten command line: -> @argfile` * [Kotlin Playground](https://play.kotlinlang.org/) * 語法參考 * https://kotlinlang.org/docs/basic-syntax.html#variables ## 剪刀石頭布遊戲 Playground 版本基本程式 ```kotlin= fun main() { // 玩家出拳 val playerChoice = "布" // 電腦出拳 val computerChoice = when ((0..2).random()) { 0 -> "剪刀" 1 -> "石頭" else -> "布" } // 判斷勝負 val result = when (playerChoice) { "剪刀" -> { when (computerChoice) { "剪刀" -> "平手" "石頭" -> "你輸了" else -> "你贏了" } } "石頭" -> { when (computerChoice) { "剪刀" -> "你贏了" "石頭" -> "平手" else -> "你輸了" } } else -> { when (computerChoice) { "剪刀" -> "你輸了" "石頭" -> "你贏了" else -> "平手" } } } // 輸出結果 println("玩家出拳:$playerChoice") println("電腦出拳:$computerChoice") println("結果:$result") } ```