コード例 #1
0
ファイル: User.java プロジェクト: CS2212-2012-G2/SurvivorPool
  /**
   * Updates the stored user with any not null information in the passed user
   *
   * @param u The user to update from.
   * @throws InvalidFieldException Thrown if anything is of the wrong format.
   */
  public void update(User u) throws InvalidFieldException {
    if (u.getFirstName() != null) {
      setFirstName(u.getFirstName());
    }

    if (u.getLastName() != null) {
      setLastName(u.getLastName());
    }

    if (u.getID() != null) {
      setID(u.getID());
    }

    if (u.getPoints() != getPoints()) {
      setPoints(u.getPoints());
    }

    if (u.getWeeklyPick() != null && !u.getWeeklyPick().isNull()) {
      setWeeklyPick(u.getWeeklyPick());
    }

    if (u.getUltimatePick() != null && !u.getUltimatePick().isNull()) {
      setUltimatePickNoSetPts(u.getUltimatePick());
    }

    if (u.getUltimatePoints() != getUltimatePoints()) {
      setUltimatePoints(u.getUltimatePoints());
    }
  }
コード例 #2
0
ファイル: User.java プロジェクト: CS2212-2012-G2/SurvivorPool
  /**
   * Compares two User objects.
   *
   * @return 0 Users are equal.
   * @return -1 User A is greater than User B.
   * @return 1 User B is greater than User A.
   */
  public int compareTo(User otherU) {
    // ugly, but works. :)
    int result = getID().compareToIgnoreCase(otherU.getID());
    if (result == 0) {
      result = getPoints() - otherU.getPoints();
      if (result == 0) {
        result = getLastName().compareToIgnoreCase(otherU.getLastName());
        if (result == 0) {
          result = getFirstName().compareToIgnoreCase(otherU.getLastName());
        }
      }
    }

    return result;
  }