Groovy web console

subscribe to the feed Subscribe
to this
site
THIG question (via #groovywebconsole)
tweet this snippet Tweet
this
script

THIG question

Published 4 months ago by Alice with tags thigquestion
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class Person {
private String name = "Unknown";
private String email = null;
private Boolean employed;
public Person (String name, boolean employed) {
  this.name = name;
  this.employed = employed;
}
public Person (String name) {
    this.name = name;
}
//Note: the interviewee's name should be kept anonymous.
public String getName() {
    if (employed == true) {
       return name;
    } else if (employed == false) {
       return "Candidate";
    }
}
}
class Interview {
List<Person> interviewers;
Person interviewee;
String room = "Human Resources";
public Interview(List<Person> interviewers, Person interviewee, String room) {
    this.interviewers = interviewers;
    this.interviewee = interviewee;
}
public void addInterviewer(String name) {
    Person interviewer = new Person(name, true);
    interviewers.add(interviewer);
}
public void commence() {
    System.out.println("We're having an interview in " + room);
    System.out.println("Interviewing: " + interviewee.getName().toUpperCase());
    System.out.println("Interviewers: ");
    for (Person person : interviewers) {
       int count = 0;
       System.out.println(count + " - " + person.getName());
    }
}
}
//Note: below line incorporates Groovy code
List<Person> interviewers = [];
Person interviewee = new Person("David");
Interview interview = new Interview(interviewers, interviewee, "Systems Conference Room");
interview.addInterviewer("Alice");
interview.commence();