package nl.camilstaps.botleagues; /** * A contestant is a process, a unique identifier and has a score. * * @author Camil Staps */ public class Contestant implements Comparable { /** The process we're running this on */ private final Process process; /** A unique identifier (can be set in the constructor */ private final int uid; /** The score */ private int score = 0; /** * Create a new contestant with default uid -1 * * @param p the process to link this contestant to */ public Contestant(Process p) { process = p; this.uid = -1; } /** * Create a new contestant with a custom uid * * @param p the process to link this contestant to * @param uid the uid */ public Contestant(Process p, int uid) { process = p; this.uid = uid; } /** * Set a new score * @param new_score */ public void setScore(int new_score) { score = new_score; } /** * Get the current score * @return */ public int getScore() { return score; } /** * Get the process * @return */ public Process getProcess() { return process; } @Override /** * We compare contestants based on their score. * Like this, we can make a ranking. */ public int compareTo(Contestant arg0) { return ((Integer) getScore()).compareTo(arg0.getScore()); } @Override public String toString() { return "Contestant " + uid + " (" + score + "): " + process.toString(); } }