java.lang.Object
edu.ntnu.idatt1002.k1g4.Cup
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 Summary
ConstructorsConstructorDescriptionCup()
Instantiates a new Cup.Cup
(String name, String location, LocalDateTime startTime, LocalDateTime endTime) Simplified constructor for instantiation of a new Cup.Cup
(String name, String location, ArrayList<Division> divisions, LocalDateTime startTime, LocalDateTime endTime) Instantiates a new Cup. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addDivision
(Division division) Method which adds division to the list of divisions.boolean
addMatchInDivision
(Division division, Match match) Finds the correct division and adds a match to the division.boolean
addTeamInDivision
(Division division, Team team) Finds the correct division and adds a team to the division.Formats a localDateTime object to dd/MM/yyy hh:mmint
getCupId()
Gets cup id.Returns a list of divisions with composition.Get-method which returns the end time of the cup.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 compositionGets location for where the cup is held.getName()
Gets the name of the cupGet-method which returns the start time of the cup.void
removeDivision
(Division division) Method which removes division to the list of divisions.boolean
removeMatchInDivision
(Division division, Match match) Finds the correct division and adds a match to the division.boolean
removeTeamInDivision
(Division division, Team team) Finds the correct division and removes a team from the division.void
setCupId
(int cupId) Sets cup id.void
setDivisions
(ArrayList<Division> divisions) Sets divisions.void
setEndTime
(LocalDateTime endTime) Mutation-method which sets end time for a cup.void
setLocation
(String location) Sets the location for where the cup is heldvoid
Changes the name of the cupvoid
setStartTime
(LocalDateTime startTime) Mutation-method which sets start time for a cup.toString()
toString-method for Cup class.
-
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 cuplocation
- 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
Simplified constructor for instantiation of a new Cup.- Parameters:
name
- String: The name of the cuplocation
- 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
Gets the name of the cup- Returns:
- name String: the name of the cup
-
setName
Changes the name of the cup- Parameters:
name
- String: the name of the cup
-
getLocation
Gets location for where the cup is held.- Returns:
- Location String: The cup location.
-
setLocation
Sets the location for where the cup is held- Parameters:
location
- String: the location of the cup
-
getStartTime
Get-method which returns the start time of the cup.- Returns:
- startTime LocalDateTime: The start time.
-
getEndTime
Get-method which returns the end time of the cup.- Returns:
- endTime LocalDateTime: The end time.
-
setStartTime
Mutation-method which sets start time for a cup.- Parameters:
startTime
- LocalDateTime: The start time.
-
setEndTime
Mutation-method which sets end time for a cup.- Parameters:
endTime
- LocalDateTime: The end time.
-
getDivisions
Returns a list of divisions with composition.- Returns:
- newDivisions ArrayList: an arraylist of divisions
-
addDivision
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
Method which removes division to the list of divisions.- Parameters:
division
- Division: Division to be removed.
-
getEqualDivision
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
Finds the correct division and adds a team to the division.- Parameters:
division
- Division: a division to find the equal ofteam
- Team: a provided team to add to the division.- Returns:
- boolean true if the division exists and the team was successfully added.
-
removeTeamInDivision
Finds the correct division and removes a team from the division.- Parameters:
division
- Division: a division to find the equal ofteam
- Team: provided team to remove from the division.- Returns:
- boolean true if the division exists and the team was successfully removed.
-
addMatchInDivision
Finds the correct division and adds a match to the division.- Parameters:
division
- Division: a division to find the equal ofmatch
- Match: a provided match to add to the division.- Returns:
- boolean true if the division exists and the match was successfully added.
-
removeMatchInDivision
Finds the correct division and adds a match to the division.- Parameters:
division
- Division: a division to find the equal ofmatch
- Match: a provided match to remove from the division.- Returns:
- boolean true if the division exists and the match was successfully removed.
-
setCupId
Sets cup id.- Parameters:
cupId
- int: the cup id- Throws:
IllegalArgumentException
- the illegal argument exception
-
setDivisions
Sets divisions.- Parameters:
divisions
- ArrayList: The divisions that the cup have.
-
getCupId
public int getCupId()Gets cup id.- Returns:
- int: the cup id
-
formatTime
Formats a localDateTime object to dd/MM/yyy hh:mm- Returns:
- String : representation of start and estimated end time
-
toString
toString-method for Cup class.
-