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

public class Cup extends Object
The type Cup. A Cup has multiple divisions corresponding to different age and gender groups.
Version:
0.5
Author:
Nicolai H. Brand, Runar Indahl, Carl Gützkow, Callum Gran
  • Constructor Details

    • Cup

      public Cup(String name, String location, ArrayList<Division> divisions, LocalDateTime startTime, LocalDateTime endTime) throws IllegalArgumentException
      Instantiates a new Cup.
      Parameters:
      name - String: The name of the cup
      location - String: The location of the cup.
      divisions - HashMap: List of divisions for this cup.
      startTime - LocalDateTime: When the cup starts.
      endTime - LocalDateTime: When the cup ends.
      Throws:
      IllegalArgumentException - If end time before start time.
    • Cup

      public Cup(String name, String location, LocalDateTime startTime, LocalDateTime endTime)
      Simplified constructor for instantiation of a new Cup.
      Parameters:
      name - String: The name of the cup
      location - String: The location of the cup.
      startTime - LocalDateTime: When the cup starts.
      endTime - LocalDateTime: When the cup ends.
    • Cup

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

    • getName

      public String getName()
      Gets the name of the cup
      Returns:
      name String: the name of the cup
    • setName

      public void setName(String name)
      Changes the name of the cup
      Parameters:
      name - String: the name of the cup
    • getLocation

      public String getLocation()
      Gets location for where the cup is held.
      Returns:
      Location String: The cup location.
    • setLocation

      public void setLocation(String location)
      Sets the location for where the cup is held
      Parameters:
      location - String: the location of the cup
    • getStartTime

      public LocalDateTime getStartTime()
      Get-method which returns the start time of the cup.
      Returns:
      startTime LocalDateTime: The start time.
    • getEndTime

      public LocalDateTime getEndTime()
      Get-method which returns the end time of the cup.
      Returns:
      endTime LocalDateTime: The end time.
    • setStartTime

      public void setStartTime(LocalDateTime startTime)
      Mutation-method which sets start time for a cup.
      Parameters:
      startTime - LocalDateTime: The start time.
    • setEndTime

      public void setEndTime(LocalDateTime endTime)
      Mutation-method which sets end time for a cup.
      Parameters:
      endTime - LocalDateTime: The end time.
    • getDivisions

      public ArrayList<Division> getDivisions()
      Returns a list of divisions with composition.
      Returns:
      newDivisions ArrayList: an arraylist of divisions
    • addDivision

      public boolean addDivision(Division division)
      Method which adds division to the list of divisions.
      Parameters:
      division - Division: Division to be added.
      Returns:
      Boolean : True if division doesn't exist and is added, false if it doesn't exist.
    • removeDivision

      public void removeDivision(Division division)
      Method which removes division to the list of divisions.
      Parameters:
      division - Division: Division to be removed.
    • getEqualDivision

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

      public boolean addTeamInDivision(Division division, Team team)
      Finds the correct division and adds a team to the division.
      Parameters:
      division - Division: a division to find the equal of
      team - Team: a provided team to add to the division.
      Returns:
      boolean true if the division exists and the team was successfully added.
    • removeTeamInDivision

      public boolean removeTeamInDivision(Division division, Team team)
      Finds the correct division and removes a team from the division.
      Parameters:
      division - Division: a division to find the equal of
      team - Team: provided team to remove from the division.
      Returns:
      boolean true if the division exists and the team was successfully removed.
    • addMatchInDivision

      public boolean addMatchInDivision(Division division, Match match)
      Finds the correct division and adds a match to the division.
      Parameters:
      division - Division: a division to find the equal of
      match - Match: a provided match to add to the division.
      Returns:
      boolean true if the division exists and the match was successfully added.
    • removeMatchInDivision

      public boolean removeMatchInDivision(Division division, Match match)
      Finds the correct division and adds a match to the division.
      Parameters:
      division - Division: a division to find the equal of
      match - Match: a provided match to remove from the division.
      Returns:
      boolean true if the division exists and the match was successfully removed.
    • setCupId

      public void setCupId(int cupId) throws IllegalArgumentException
      Sets cup id.
      Parameters:
      cupId - int: the cup id
      Throws:
      IllegalArgumentException - the illegal argument exception
    • setDivisions

      public void setDivisions(ArrayList<Division> divisions)
      Sets divisions.
      Parameters:
      divisions - ArrayList: The divisions that the cup have.
    • getCupId

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

      public String formatTime()
      Formats a localDateTime object to dd/MM/yyy hh:mm
      Returns:
      String : representation of start and estimated end time
    • toString

      public String toString()
      toString-method for Cup class.
      Overrides:
      toString in class Object
      Returns:
      string: representation of a cup