/* * Created on Jun 29, 2004 */ package baseball; import java.util.List; /** * @author dickey */ public class Team implements Comparable { String teamName; String hittingAvg; List players; public Team(String tname, String hittingAvg) { this.teamName = tname; this.hittingAvg = hittingAvg; } public String toString() { return this.teamName + " batting average: " + this.hittingAvg; } /** Compare teams, based on team name (using the standard String * comparison). * * @param otherTeam an object which must be a Team. * @return < 1 if this team name comes before the other; > 1 * if it comes after; 0 if they are the same. */ public int compareTo(Object otherTeam) { String otherTeamName = ((Team) otherTeam).teamName; return this.teamName.compareToIgnoreCase(otherTeamName); } }