import java.util.*; public class Candidate extends ArrayList implements Comparable { String name; public Candidate(String name) { this.name = name; } public String toString() { return this.name + super.toString(); } public int compareTo(Candidate other) { if (this.size() > other.size()) return -1; else if (this.size() < other.size()) return 1; else return this.name.compareTo(other.name); } public double sum() { double a = 0; for (Integer n : this) a += n; return a; } public double average() { return this.sum() / this.size(); } }