Groovy web console

subscribe to the feed Subscribe
to this
site

RandomTeam

Published 1 month ago by Luke with tags test
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
public String teamInfo(String name, String[] comments)
{
    // Use Random class to pick a comment from array ^
    Random rnd = new Random();   
    return comments[rnd.nextInt(comments.size())];
}

String[] teamNames = ["Luke","Kristel","Sarah","Ana","Adam","Damien","Jaiden"];
String[] teamComments = ["is cool","is boring","is legendary","takes the cake","has a nice butt","is a nerd","hates fun",
                         "is nice","is good at coding","is a superstar","loves love","is in love","hates squirrels","likes cake","is a robot",
                         "is a terminator","is an AI","likes playing with fire","can't read","is short","has nice eyes","is stunning"];

// For each name in teamNames, append a random trait
for (int i = 0; i < teamNames.size(); i++){
    println (teamNames[i] + " " + teamInfo(teamNames[i],teamComments));
}