Class Division

java.lang.Object
edu.ntnu.idatt1002.k1g4.Division

public class Division extends Object
This class keeps track of a division in the tournament.
Version:
0.7
Author:
Brage H. Kvamme, Nicolai H. Brand, Runar Indahl, Carl Gützkow, Callum Gran
  • Constructor Details

    • Division

      public Division(HashMap<Integer,Team> competingTeams, ArrayList<Match> matches, String divisionCategory, int cupId) throws IllegalArgumentException
      Instantiates a new Division.
      Parameters:
      competingTeams - HashMap: the competing teams in this division.
      matches - ArrayList: the matches that have been played in this division.
      divisionCategory - String: the division which is competed in.
      cupId - int: the cup id of the division.
      Throws:
      IllegalArgumentException - if category is empty
    • Division

      public Division(String divisionCategory, int cupId)
      Instantiates a new division. Simplified Constructor which allows a division to be established without a list of teams and matches.
      Parameters:
      divisionCategory - String: the division which is competed in.
      cupId - int: the cup id of the division.
    • Division

      public Division()
      Instantiates a new Division. This constructor is for data from the database.
  • Method Details

    • addTeam

      public boolean addTeam(Team team)
      Add a team to the list of competing teams.
      Parameters:
      team - Team: a competing team.
      Returns:
      boolean true if team was added, false if not.
    • removeTeam

      public boolean removeTeam(Team team)
      Remove a team.
      Parameters:
      team - Team: a competing team.
      Returns:
      boolean : true if team was removed, false if not.
    • addMatch

      public boolean addMatch(Match match) throws IllegalArgumentException
      Add a match to the list of matches.
      Parameters:
      match - Match: the match to be added to the division
      Returns:
      Boolean : True if match not exist and then adds the match. False if already exists.
      Throws:
      IllegalArgumentException - the illegal argument exception
    • removeMatch

      public boolean removeMatch(Match match)
      Remove a match from the list of matches.
      Parameters:
      match - Match: the match to be removed.
      Returns:
      boolean : true when match is removed.
    • getCompetingTeams

      public HashMap<Integer,Team> getCompetingTeams()
      Creates and return a deep copy of competing teams list.
      Returns:
      HashMap : a list of competing teams.
    • getMatches

      public ArrayList<Match> getMatches()
      Return the list of matches.
      Returns:
      matches ArrayList: the list of matches in this division.
    • getDivisionCategory

      public String getDivisionCategory()
      Returns the division category.
      Returns:
      divisionCategory String: the division which is competed in.
    • getProjectedGeneratedMatches

      public int getProjectedGeneratedMatches()
      Gets the projected amount of matches generated. Integer division by two on total teams
      Returns:
      int : amount of matches to be generatd
    • getEqualMatch

      public Match getEqualMatch(Match match)
      Helper method to get the match that is equal to the object that is provided This is to solve the problems with composition
      Parameters:
      match - Match: Match - a division to find the equal of
      Returns:
      match Match: a match that is in the list. Might be null
    • genRandomMatches

      public boolean genRandomMatches(LocalDateTime startTime, int duration, String[] fields, int divisionId)
      Create random matches.
      Parameters:
      startTime - the start time
      duration - the duration
      fields - the fields
      divisionId - the division id
      Returns:
      the list
    • setDivisionId

      public void setDivisionId(int divisionId) throws IllegalArgumentException
      Sets division id.
      Parameters:
      divisionId - int: the division id
      Throws:
      IllegalArgumentException - the illegal argument exception
    • setCompetingTeams

      public void setCompetingTeams(HashMap<Integer,Team> competingTeams)
      Sets competing teams in a division.
      Parameters:
      competingTeams - ArrayList: The competing teams
    • setMatches

      public void setMatches(ArrayList<Match> matches)
      Sets matches in a division.
      Parameters:
      matches - ArrayList: The matches
    • setDivisionCategory

      public void setDivisionCategory(String divisionCategory) throws IllegalArgumentException
      Sets division category.
      Parameters:
      divisionCategory - String: The division category
      Throws:
      IllegalArgumentException - the illegal argument exception
    • getDivisionId

      public int getDivisionId()
      Gets division id.
      Returns:
      divisionId int : the division id
    • setCupId

      public void setCupId(int cupId)
      Sets cup id of the division.
      Parameters:
      cupId - int: the cup id
    • getCupId

      public int getCupId()
      Gets cup id.
      Returns:
      cupId int : the cup id
    • equals

      public boolean equals(Object o)
      override equals method
      Overrides:
      equals in class Object
      Parameters:
      o - Object: object to be compared
      Returns:
      boolean: true if ageClass and sexClass are equal
    • hashCode

      public int hashCode()
      gets hashcode
      Overrides:
      hashCode in class Object
      Returns:
      0 int: the hashcode
    • toString

      public String toString()
      toString method
      Overrides:
      toString in class Object
      Returns:
      String: toString