title: Created a method to calculate Team with most wins and winning percentage
body: <p>I'm learning how to utilize Linked lists in my second semester Java class. For our program we are supposed to code a class encapsulating the idea of football teams with wins and losses. </p>
  
  <p>The part I need help on is creating a method that returns the nicknames of the 3 teams with the most wins and another that returns the five best teams based on winning percentages. </p>
  
  <p>Team Class</p>
  
  <pre><code>public class Team
  {
      private int GamesWon;
      private int GamesLost;
      private String Team;
  
      public Team (int i, int j, String k)
      {
          GamesWon = i;
          GamesLost = j;
          Team = k;
      }
  
      public int getGamesWon()
      {
          return GamesWon;
      }
      public int getGamesLost()
      {
          return GamesLost;
      }
      public String getTeam()
      {
          return Team;
      }
      public void setGamesWon(int i)
      {
          GamesWon = i;
      }
      public void setGamesLost(int j)
      {
          GamesLost = j;
      }
      public void setTeam(String k)
      {
          Team = k;
      }
      public String toString()
      {
          return("Team: " + Team + "\tGamesWon: " + GamesWon + "\tGamesLost: " + GamesLost);
      }
  }
  </code></pre>
  
  <p>TeamNode Class</p>
  
  <pre><code>public class TeamNode 
  {
      private Team team;
      private TeamNode next;
  
  public TeamNode()
  {
      team = null;
      next = null;
  }
  
  public TeamNode(Team t)
  {
      setTeam(t);
      next = null;
  }
  
  
  public Team getTeam()
  {
      return team;
  }
  
  public TeamNode getNext()
  {
      return next;
  }
  
  public void setTeam(Team t)
  {
      team = t;
  }
  
  public void setNext(TeamNode tn)
  {
      next = tn;
  }
  
  
  
  }
  </code></pre>
  
  <p>ShellLinkedList</p>
  
  <pre><code>public abstract class ShellLinkedList
  {
      protected TeamNode head;
      protected int numberOfItems;
  
  public ShellLinkedList()
  {
      head = null;
      numberOfItems = 0;
  }
  
  public int getNumberOfItems()
  {
      return numberOfItems;
  }
  
  public boolean isEmpty()
  {
      return (numberOfItems == 0);
  }
  public String toString()
  {
      String listString = "";
      TeamNode current = head;
      while (current != null)
      {
          listString += current.getTeam().toString() + "\n";
      current = current.getNext();
      }
      return listString;
  }
  
  }
  </code></pre>
  
  <p>DataStructureExcetion(error class)</p>
  
  <pre><code>public class DataStructureException extends Exception
  {
  public DataStructureException(String s)
  {
      super(s);
  }
  }
  </code></pre>
  
  <p>Team linked list class</p>
  
  <pre><code>public class TeamLinkedList extends ShellLinkedList
  {
  public TeamLinkedList()
  {
      super();
  }
  public void insert(Team t)
  {
      TeamNode tn = new TeamNode(t);
      tn.setNext(head);
      head = tn;
      numberOfItems++;
  }
  public Team delete(String searchName)
                          throws DataStructureException
  {
      TeamNode current = head;
      TeamNode previous = null;
      while (current != null &amp;&amp; current.getTeam().getTeam() != searchName)
      {
          previous = current;
          current = current.getNext();
      }
  
      if (current == null)
          throw new DataStructureException(searchName + " not found: cannot be deleted");
      else
      {
          if (current == head)
              head = head.getNext();
          else
              previous.setNext(current.getNext());
              numberOfItems--;
          return current.getTeam();
      }
  }
  }
  </code></pre>
  
  <p>Client class</p>
  
  <pre><code>public class TeamLinkedListTest 
  {
      public static void main(String [] args)
      {
  
          Team t1 = new Team (10, 0, "Patriots" );
          Team t2 = new Team (9, 1, "49ners");
          Team t3 = new Team (8, 2, "Chargers");
          Team t4 = new Team (7, 3, "Bengals");
          Team t5 = new Team (6, 4,"Jets");
          Team t6 = new Team (5, 5, "Raiders");
          Team t7 = new Team (4, 6, "Seahawks");
          Team t8 = new Team (3, 7, "Cardinals");
          Team t9 = new Team (2, 8, "Texans");
          Team t10 = new Team(1, 9, "Dolphins");
  
          TeamLinkedList Team = new TeamLinkedList();
          System.out.println("Number of items in the list: " + Team.getNumberOfItems() + "\n" + Team.toString());
  
          Team.insert(t1);
          System.out.println("Number of items in the list: " + Team.getNumberOfItems() + "\n" + Team.toString());
  
          Team.insert(t2);
          System.out.println("Number of items in the list: " + Team.getNumberOfItems() + "\n" + Team.toString());
  
          Team.insert(t3);
          System.out.println("Number of items in the list: " + Team.getNumberOfItems() + "\n" + Team.toString());
  
          Team temp;
  
          try
          {
              temp = Team.delete("Bengals");
              System.out.println("Team deleted: " + temp);
          }
          catch(DataStructureException dse1)
          {
              System.out.println(dse1.getMessage() + "\n");
          }
  
          try
          {
              temp = Team.delete("Patriots");
              System.out.println("Deleted " + temp);
              System.out.println("Number of items in the list: " + Team.getNumberOfItems() + "\n" + Team.toString());
  
              temp = Team.delete("49ners");
              System.out.println("Deleted " + temp);
              System.out.println("Number of items in the list: " + Team.getNumberOfItems() + "\n" + Team.toString());
  
              temp = Team.delete("Chargers");
              System.out.println("Deleted " + temp);
              System.out.println("Number of items in the list: " + Team.getNumberOfItems() + "\n" + Team.toString());
  
              temp = Team.delete("Patriots");
              System.out.println("Deleted " + temp);
              System.out.println("Number of items in the list: " + Team.getNumberOfItems() + "\n" + Team.toString());
          }
          catch(DataStructureException dse2)
          {
              System.out.println(dse2.getMessage());
          }
  
      }
  }
  </code></pre>