Example #1
0
  /** This method finds the winners of each age bracket. */
  public void findWinners() {
    int age;
    for (Contestant contestant : myContestants) {
      try {

        age = Integer.parseInt(contestant.getMyAge());
      } catch (Exception e) {
        continue;
      }
      if (age < 6) {
        if (winner5 == null) {
          winner5 = contestant;
        } else if (Float.parseFloat(winner5.getMyAverageScore())
            < Float.parseFloat(contestant.getMyAverageScore())) {
          winner5 = contestant;
        }
      } else if (age < 11) {
        if (winner10 == null) {
          winner10 = contestant;
        } else if (Float.parseFloat(winner10.getMyAverageScore())
            < Float.parseFloat(contestant.getMyAverageScore())) {
          winner10 = contestant;
        }
      } else if (age < 16) {
        if (winner15 == null) {
          winner15 = contestant;
        } else if (Float.parseFloat(winner15.getMyAverageScore())
            < Float.parseFloat(contestant.getMyAverageScore())) {
          winner15 = contestant;
        }
      } else if (age < 19) {
        if (winner18 == null) {
          winner18 = contestant;
        } else if (Float.parseFloat(winner18.getMyAverageScore())
            < Float.parseFloat(contestant.getMyAverageScore())) {
          winner18 = contestant;
        }
      } else if (age > 18) {
        if (winner19 == null) {
          winner19 = contestant;
        } else if (Float.parseFloat(winner19.getMyAverageScore())
            < Float.parseFloat(contestant.getMyAverageScore())) {
          winner19 = contestant;
        }
      }
    }
  }