以前试过,忘得差不多了,趁这次从JAVA一直撸到SERVLET,SPRING,GROOVY,GRAILS的机会,再弄一次吧。。。

def authors = [
    "Peter Ledbrook",
    "Glen Smith"
]

def quoteParts = [
    ["Time", "waits", "for no man"],
    ["The roundhouse kick", "solves", "all problems"],
    ["Groovy", "is", "the bees knees"]
]

for (i in 0..10) {
    def quote = createQuote(quoteParts, authors)
    println quote
}

String createQuote(List quoteParts, List authors) {
    def rand = new Random()
    def n = quoteParts.size()
    def m = authors.size()

    return quoteParts[rand.nextInt(n)][0] + ' ' +
        quoteParts[rand.nextInt(n)][1] + ' ' +
        quoteParts[rand.nextInt(n)][2] + ' by ' +
        authors[rand.nextInt(m)]
} 

最新文章

  1. AFNetworking的封装
  2. 利用jQuery对插件进行扩展时,方法$.extend()、$.fn.extend()区别与联系
  3. WebLogic中的一些基本概念
  4. js控住DOM实现发布微博简单效果
  5. 初识Hadoop入门介绍
  6. 一款查看mysql QPS的脚本
  7. 【CSU1808】地铁
  8. javascript的变量、作用域和内存问题
  9. SQLite简介
  10. SqlServer 查询死锁,杀死死锁进程
  11. 深入理解Java内部类
  12. js 正则进阶regexp
  13. sql 同步2个表中的一个字段数据
  14. Kotlin(一)
  15. web集成高德地图
  16. Mac OS X 下优化 Terminal,一篇就够了!
  17. python之Django实现商城从0到1
  18. Leetcode题库——36.有效的数独
  19. output-operations-on-dstreams
  20. kernel jenkins build script

热门文章

  1. hdu1814Peaceful Commission(2-SAT)
  2. 解决macOS升级之后每次使用ssh都要输入密码的问题
  3. MySQL简明教程---级联约束
  4. PHP开发之旅-表单验证
  5. PHP第二阶段学习 一、php的基本语法
  6. Mongodb 重置密码或创建用户
  7. Coding iOS客户端应用源码
  8. day04-交互、格式化输出及基本运算符
  9. 一台电脑同时使用多个Git账号
  10. cocos creator游戏适配这事