thinkofanumber.groovy
来自「大名鼎鼎的java动态脚本语言。已经通过了sun的认证」· GROOVY 代码 · 共 22 行
GROOVY
22 行
/** * Simple game * @author: Jeremy Rayner * based on algorithms from INPUT/Marshall Cavendish/1984 */while (true) { try { int x = Math.random() * 6 print "The computer has chosen a number between 0 and 5. Can you guess it?" def line = System.in.readLine() int g = line.toInteger() if (g == x) { println "Well done" } else { println "Tough luck - you're wrong" } } catch (NumberFormatException e) { println "The computer didn't understand '$line'" }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?