Exemplo n.º 1
0
  public static void main(String[] args) {
    /*
    ArrayList<Team> teams;
    Collections.sort(teams); -> implement Comparable interface (compareTo)
       Generic class -> league, has tourney table for a sport
           stores lists of teams in league
           teams can be added to list
           method that prints teams in order based on ranking (highest to lowest)

           leagues can only accept teams of same type
           incompatible team should throw compiler error
     */
    League<Team<FootballPlayer>> footballLeague = new League<>("AFL");
    Team<FootballPlayer> adelaideCrows = new Team<>("Adelaide Crows");
    Team<FootballPlayer> melbourne = new Team<>("Melbourne");
    Team<FootballPlayer> hawthorn = new Team<>("Hawthorn");
    Team<FootballPlayer> fremantle = new Team<>("Fremantle");
    Team<BaseballPlayer> baseballTeam = new Team<>("Chicago Cubs");

    hawthorn.matchResult(fremantle, 1, 0);
    hawthorn.matchResult(adelaideCrows, 3, 8);

    adelaideCrows.matchResult(fremantle, 2, 1);

    footballLeague.add(adelaideCrows);
    footballLeague.add(melbourne);
    footballLeague.add(hawthorn);
    footballLeague.add(fremantle);

    footballLeague.showLeagueTable();
  }