Groovy web console

subscribe to the feed Subscribe
to this
Fixing Alice's Script (via #groovywebconsole)
tweet this snippet Tweet

Fixing Alice's Script

Published 1 year ago by hlaaftana with tags alice groovified
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class Person {
    private String name
    private String email
    private boolean employed
    Person (String name, boolean employed = false) { = name
        this.employed = employed
    //Note: the interviewee's name should be kept anonymous.
    String getName() {
        employed ? name : "Candidate"

class Interview {
    List<Person> interviewers
    Person interviewee
    String room = "Human Resources"
    Interview(List<Person> interviewers, Person interviewee, String room) {
        this.interviewers = interviewers;
        this.interviewee = interviewee;
    void addInterviewer(String name) {
        interviewers << new Person(name, true)
    void commence() {
        println "We're having an interview in $room"
        println "Interviewing: ${}"
        println "Interviewers: "
        for (int i = 0; i < interviewers.size(); ++i) 
            println "$i - ${interviewers[i].name}"
//Note: below line incorporates Groovy code
List<Person> interviewers = []
Person interviewee = new Person('David')
Interview interview = new Interview(interviewers, interviewee, 'Systems Conference Room')