// CSE 143, Winter 2011, Marty Stepp // A TA object represents one teaching assistant. public class TA implements Comparable { private String name; private int experience; // # of quarters served as a TA // Constructs a new TA with given name and number of quarters' experience. // Throws IllegalArgumentException if name is null or experience is negative. public TA(String name, int experience) { if (name == null || experience < 0) { throw new IllegalArgumentException(); } this.name = name; this.experience = experience; } // Returns the TA's name. public String getName() { return name; } // Returns the TA's quarters of experience. public int getExperience() { return experience; } // Returns string with name and number of quarters, such as "Kim (5q)". public String toString() { return name + " (" + experience + "q)"; } public int compareTo(TA other) { if (experience != other.getExperience()) { return experience - other.getExperience(); } else { // same # of qtrs experience; break tie by name return name.compareTo(other.getName()); } } }