-
-
Save sudoyu/baef97d14360169b8ccf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ikeametal | |
class QuestionController { | |
List ikeas = ["Vittsjö","Klubbo","Bastig","Boholmen","Grundtal","Dåtid","Samsplet","Skogaby","Adde","Nyvoll","Strandmon","Krokig","Vyssa Skont","Melltorp","Vridvinge"] | |
List metals = ["Akercocke","Einherjer","Sargeist","Taake","Ensiferum","Midnattsol","Turisas","Thaurorod","Sikth","Eluveitie","Månegarm","Kovenant","Korpiklaani"] | |
Random rand = new Random() | |
static Integer total = 0 | |
static Integer correct = 0 | |
def index() { | |
List joined = metals + ikeas | |
def picked = joined[ rand.nextInt(joined.size()) ] | |
render "<H1>$picked</H1> is IKEA or METAL ?" + | |
g.link(action:"ikea",id:picked){"<H2>IKEA</H2>"} + | |
g.link(action:"metal",id:picked){"<H2>METAL</H2>"} + | |
"( $correct / $total )" | |
} | |
def metal() { | |
total ++ | |
def ans = metals.contains(params.id) ? | |
"<H1>Right!</H1> ${params.id} is Metal Band.<!--${++correct}-->" : | |
"<H1>Wrong.</H1> ${params.id} is IKEA Item." | |
ans += g.link(action:"index"){"<H2>Next</H2>"}+"( $correct / $total )" | |
render ans | |
} | |
def ikea() { | |
total ++ | |
def ans = ikeas.contains(params.id) ? | |
"<H1>Right!</H1> ${params.id} is IKEA Item.<!--${++correct}-->" : | |
"<H1>Wrong.</H1> ${params.id} is Metal Band." | |
ans += g.link(action:"index"){"<H2>Next</H2>"}+"( $correct / $total )" | |
render ans | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment