java.lang.Object
edu.ntnu.idatt1002.k1g4.client.Model

public class Model extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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 arraylist
    static 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.
    static ArrayList<Cup>
    Returns the static list of cups
    static Cup
    Returns the current cup set.
    static Division
    Returns the division that is currently selected
    static Match
    Returns the match that is currently selected
    static Team
    returns the selected team
    static void
    openBrowser(String urlString)
    Open browser.
    static void
    Sets the current cup to a new value
    static void
    Selects a new division as the current one
    static void
    Selects a new match as the current one
    static void
    setCurrentTeam(Team newCurrentTeam)
    sets the current team
    static 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Model

      public Model()
  • Method Details

    • getCups

      public static ArrayList<Cup> getCups()
      Returns the static list of cups
      Returns:
      cups an arraylist of cups
    • getCurrentCup

      public static Cup getCurrentCup()
      Returns the current cup set.
      Returns:
      currentCup Cup: The last cup selected
    • setCurrentCup

      public static void setCurrentCup(Cup newCup)
      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

      public static Division getCurrentDivision()
      Returns the division that is currently selected
      Returns:
      currentDivision Division: the currently selected division
    • setCurrentDivision

      public static void setCurrentDivision(Division newDivision)
      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

      public static Match getCurrentMatch()
      Returns the match that is currently selected
      Returns:
      currentMatch Match: the currently selected match
    • setCurrentMatch

      public static void setCurrentMatch(Match newMatch)
      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

      public static Team getCurrentTeam()
      returns the selected team
      Returns:
      currentTeam Team: the current selected team
    • setCurrentTeam

      public static void setCurrentTeam(Team newCurrentTeam)
      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 field
      cupLocationField - TextField: the cup location field
      startDateField - DatePicker: the start date field
      startTimeField - TextField: the start time field
      endDateField - DatePicker: the end date field
      endTimeField - 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 team
      teamTwoComBox - ComboBox: A combo box with the same teams as teamOneComBox to set the second team
      startTimeField - TextField: A date field to set the start date of the match
      startDateField - DatePicker: A time field to set the start time of the match
      fieldField - TextField: A text field to set the field of the match
      durationField - Spinner A spinner of Integers parsed to long to set the duration of the match
      isKnockout - 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

      public static void openBrowser(String urlString) throws IOException, URISyntaxException
      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 exception
      URISyntaxException - the uri syntax exception