java.lang.Object
edu.ntnu.idatt1002.k1g4.client.Model
The type Model.
This will NOT be a model as in the MVC (model, view, controller) structure.
We take ideas and principle from the MVC structure, but adapt it to suit our needs.
See the project wiki on gitlab https://gitlab.stud.idi.ntnu.no/carljgu/tournament-service/-/wikis/home
for how this class relates to the Controllers and ViewUtil.
- Version:
- 0.9
- Author:
- Carl Gützkow, Nicolai H. Brand, Runar Indahl, Callum Gran
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
createCup
(javafx.scene.control.TextField cupNameField, javafx.scene.control.TextField cupLocationField, javafx.scene.control.DatePicker startDateField, javafx.scene.control.TextField startTimeField, javafx.scene.control.DatePicker endDateField, javafx.scene.control.TextField endTimeField) Create cup.static boolean
createDivision
(javafx.scene.control.TextField textFieldDivisionCategory) Creates a new division from given fields.static boolean
createMatch
(javafx.scene.control.ComboBox<Team> teamOneComBox, javafx.scene.control.ComboBox<Team> teamTwoComBox, javafx.scene.control.TextField startTimeField, javafx.scene.control.DatePicker startDateField, javafx.scene.control.TextField fieldField, javafx.scene.control.Spinner<Integer> durationField, javafx.scene.control.RadioButton isKnockout) Creates a new match with the given fields.static boolean
createTeam
(javafx.scene.control.TextField teamNameField) Create team boolean.static void
removes the selected cup from the cups arrayliststatic void
Delete selected division.static void
Delete selected match.static boolean
generateMatches
(javafx.scene.control.DatePicker startDateField, javafx.scene.control.TextField startTimeField, javafx.scene.control.Spinner<Integer> durationField, javafx.scene.control.TextField fieldField) Generate random matches.getCups()
Returns the static list of cupsstatic Cup
Returns the current cup set.static Division
Returns the division that is currently selectedstatic Match
Returns the match that is currently selectedstatic Team
returns the selected teamstatic void
openBrowser
(String urlString) Open browser.static void
setCurrentCup
(Cup newCup) Sets the current cup to a new valuestatic void
setCurrentDivision
(Division newDivision) Selects a new division as the current onestatic void
setCurrentMatch
(Match newMatch) Selects a new match as the current onestatic void
setCurrentTeam
(Team newCurrentTeam) sets the current teamstatic void
Sets no current cup.static void
Sets no current division.static void
Sets no current match.static void
Sets current team to null.static void
updateMatchScore
(int team, int newScore) Updates the score for a team in a match.
-
Constructor Details
-
Model
public Model()
-
-
Method Details
-
getCups
Returns the static list of cups- Returns:
- cups an arraylist of cups
-
getCurrentCup
Returns the current cup set.- Returns:
- currentCup Cup: The last cup selected
-
setCurrentCup
Sets the current cup to a new value- Parameters:
newCup
- Cup: a cup that is to be selected
-
setNoCurrentCup
public static void setNoCurrentCup()Sets no current cup. -
getCurrentDivision
Returns the division that is currently selected- Returns:
- currentDivision Division: the currently selected division
-
setCurrentDivision
Selects a new division as the current one- Parameters:
newDivision
- Division: the new division to be selected
-
deleteSelectedDivision
public static void deleteSelectedDivision()Delete selected division. -
deleteSelectedCup
public static void deleteSelectedCup()removes the selected cup from the cups arraylist -
setNoCurrentDivision
public static void setNoCurrentDivision()Sets no current division. -
getCurrentMatch
Returns the match that is currently selected- Returns:
- currentMatch Match: the currently selected match
-
setCurrentMatch
Selects a new match as the current one- Parameters:
newMatch
- Match: the new match to be selected
-
deleteSelectedMatch
public static void deleteSelectedMatch()Delete selected match. -
setNoCurrentMatch
public static void setNoCurrentMatch()Sets no current match. -
setNoCurrentTeam
public static void setNoCurrentTeam()Sets current team to null. -
getCurrentTeam
returns the selected team- Returns:
- currentTeam Team: the current selected team
-
setCurrentTeam
sets the current team- Parameters:
newCurrentTeam
- Team: the team to be selected
-
createCup
public static boolean createCup(javafx.scene.control.TextField cupNameField, javafx.scene.control.TextField cupLocationField, javafx.scene.control.DatePicker startDateField, javafx.scene.control.TextField startTimeField, javafx.scene.control.DatePicker endDateField, javafx.scene.control.TextField endTimeField) Create cup. Gets input information from the CupController. Tries to parse it's input and create a Cup object. Returns true if a new Cup was created and false if not.- Parameters:
cupNameField
- TextField: the cup name fieldcupLocationField
- TextField: the cup location fieldstartDateField
- DatePicker: the start date fieldstartTimeField
- TextField: the start time fieldendDateField
- DatePicker: the end date fieldendTimeField
- TextField: the end time field- Returns:
- result boolean true if the cup was successfully created
-
createDivision
public static boolean createDivision(javafx.scene.control.TextField textFieldDivisionCategory) Creates a new division from given fields. Give alerts if something fails. Returns true to if the division is created- Parameters:
textFieldDivisionCategory
- TextField: text field for division category.- Returns:
- result boolean true if the division was created. False otherwise
-
createMatch
public static boolean createMatch(javafx.scene.control.ComboBox<Team> teamOneComBox, javafx.scene.control.ComboBox<Team> teamTwoComBox, javafx.scene.control.TextField startTimeField, javafx.scene.control.DatePicker startDateField, javafx.scene.control.TextField fieldField, javafx.scene.control.Spinner<Integer> durationField, javafx.scene.control.RadioButton isKnockout) Creates a new match with the given fields. If something fails it will give an error with the ViewUtils class. Returns true if the match is created.- Parameters:
teamOneComBox
- ComboBox: A combo box with teams to set the first teamteamTwoComBox
- ComboBox: A combo box with the same teams as teamOneComBox to set the second teamstartTimeField
- TextField: A date field to set the start date of the matchstartDateField
- DatePicker: A time field to set the start time of the matchfieldField
- TextField: A text field to set the field of the matchdurationField
- Spinner A spinner of Integers parsed to long to set the duration of the matchisKnockout
- the is knockout- Returns:
- result boolean true if the match was successfully created
-
generateMatches
public static boolean generateMatches(javafx.scene.control.DatePicker startDateField, javafx.scene.control.TextField startTimeField, javafx.scene.control.Spinner<Integer> durationField, javafx.scene.control.TextField fieldField) Generate random matches.- Parameters:
startDateField
- DatePicker: the start date of the match.startTimeField
- TextField: the start time of the match.durationField
- SpinnerField: the duration of the match.fieldField
- TextField: the field the match is to be played on.- Returns:
- result boolean: true or false if the matches were generated.
-
createTeam
public static boolean createTeam(javafx.scene.control.TextField teamNameField) Create team boolean.- Parameters:
teamNameField
- TextField: a text field to set the team name- Returns:
- result boolean true if the team was successfully created
-
updateMatchScore
public static void updateMatchScore(int team, int newScore) Updates the score for a team in a match.- Parameters:
team
- int team to increase score.newScore
- int new score for the team.
-
openBrowser
Open browser. Is necessary because some variants of Unix doesn't use a desktop manager and would then just show a blank scene on Desktop.getDesktop().- Parameters:
urlString
- String: the url string- Throws:
IOException
- the io exceptionURISyntaxException
- the uri syntax exception
-