Package View

Class MainPageController

java.lang.Object
View.MainPageController

public class MainPageController extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    The editParameters function allows the user to edit their nickname, IP address and port number.
    The getMainPage function is a static function that returns the singleton instance of the MainPageController class.
    javafx.scene.Scene
    The getScene function is used to load the main-page.fxml file and return a Scene object that can be used in the Main class to set up the stage for this scene.
    void
    The hostGame function is called when the host button is clicked.
    void
    The joinGame function is called when the user clicks on the "Join Game" button.
    void
    setPage(javafx.stage.Stage stage)
    The setPage function is used to set the stage of the current page.

    Methods inherited from class java.lang.Object

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

    • MainPageController

      public MainPageController()
  • Method Details

    • getMainPage

      public static MainPageController getMainPage() throws IOException
      The getMainPage function is a static function that returns the singleton instance of the MainPageController class. This function is used to ensure that only one instance of this class exists at any given time, and it also allows for easy access to this object from other classes. The getMainPage function takes no parameters and returns an object of type MainPageController. If there are no instances of the MainPageController class currently in existence, then a new one will be created before being returned by this method.
      Returns:
      A mainpagecontroller object
      Throws:
      IOException
    • getScene

      public javafx.scene.Scene getScene() throws IOException
      The getScene function is used to load the main-page.fxml file and return a Scene object that can be used in the Main class to set up the stage for this scene.
      Returns:
      A scene object
      Throws:
      IOException
    • joinGame

      public void joinGame() throws IOException
      The joinGame function is called when the user clicks on the "Join Game" button. It creates a new GuestModel object, which will attempt to connect to a server at the IP address and port number specified by the user in their respective text fields.
      Throws:
      IOException
    • hostGame

      public void hostGame() throws IOException
      The hostGame function is called when the host button is clicked. It creates a new HostModel object, which will be used to create a ScrabbleViewModel object. The ScrabbleViewModel object will then be used to swap scenes and start the game.
      Throws:
      IOException
    • editParameters

      public void editParameters()
      The editParameters function allows the user to edit their nickname, IP address and port number. The function is called when the "EDIT" button is clicked. When this happens, all three text fields are set to be editable by the user. If they click on "SAVE", then all three text fields are no longer editable by the user and their changes will be saved in those respective variables for future use.
    • setPage

      public void setPage(javafx.stage.Stage stage)
      The setPage function is used to set the stage of the current page.
      Parameters:
      stage - Set the stage for the scene