All pastes #986941 Raw Edit

tits

public text v1 · immutable
·published 2008-04-16 02:22 UTC
rendered paste body
/*
 * Team.java
 *
 * Version: 
 *     $Id:$
 *
 * Revisions:
 *     $Log:$ 
 *
 */

//team name, the number of wins this team has during the regular season,
//and a value that indicates the strength of schedule
import java.util.ArrayList;
import java.util.Collections;

public class Team {
	String name;
	int numWins;
	int strength;

	public Team(String nam, int numwins, int stren) {
		name = nam;
		numWins = numwins;
		strength = stren;
	}

	public boolean equals(Object other) {
		boolean eq = false;
		Team temp = ((Team) other);
		if (temp.getWins() == numWins && temp.getTeamName() == name
				&& temp.getStrengthOfSchedule() == strength) {
			eq = true;
		}
		return eq;
	}

	public int compareTo(Team other) {
		int comp = 0;
		ArrayList<String> teams = new ArrayList<String>(2);
		teams.add(name);
		teams.add(other.getTeamName());
		Collections.sort(teams);
		if (numWins > other.getWins()) {
			comp = -1;
		}
		if (numWins < other.getWins()) {
			comp = 1;
		}
		if (numWins == other.getWins()
				&& strength < other.getStrengthOfSchedule()) {
			comp = 1;
		}
		if (numWins == other.getWins()
				&& strength > other.getStrengthOfSchedule()) {
			comp = -1;
		}
		if (numWins == other.getWins()
				&& strength == other.getStrengthOfSchedule()) {
			if (teams.get(0) == name) {
				comp = -1;
			} else {
				comp = 1;
			}
		}
		return comp;
	}

	public String getTeamName() {
		return name;
	}

	public int getWins() {
		return numWins;
	}

	public int getStrengthOfSchedule() {
		return strength;
	}

	public String toString() {
		String temp = "team: " + name + " has: " + numWins
				+ " wins under a schedule whose strength was rated: "
				+ strength + " out of 10.";
		return temp;
	}

}