Package view.data

Class ViewSharedData

java.lang.Object
view.data.ViewSharedData
All Implemented Interfaces:
Observer

public class ViewSharedData extends Object implements Observer
  • Constructor Summary

    Constructors
    Constructor
    Description
    The ViewSharedData function is a constructor for the ViewSharedData class.
  • Method Summary

    Modifier and Type
    Method
    Description
    The getCalculationServer function returns the calculationServer object.
    boolean
    The getHost function returns the boolean value of isHost.
    The getHostIp function returns the hostIp variable.
    int
    The getHostPort function returns the port number of the host.
    The getPlayer function returns the player object.
    The getViewModel function returns the viewModel object.
    void
    setCalculationServer(MyServer calculationServer)
    The setCalculationServer function sets the calculationServer variable to a new MyServer object.
    void
    The setGameModelReceiver function is used to set the gameModelReceiver variable.
    void
    setHost(boolean host)
    The setHost function sets the isHost variable to true or false.
    void
    setHostIp(String hostIp)
    The setHostIp function sets the hostIp variable to a new value.
    void
    setHostPort(int hostPort)
    The setHostPort function sets the hostPort variable to the value of its parameter.
    void
    setPlayer(Client player)
    The setPlayer function sets the player variable to a new Client object.
    void
    setPlayerName(String playerName)
    The setPlayerName function sets the player's name to a new value.
    void
    The update function is called by the Observable object when it has changed.

    Methods inherited from class java.lang.Object

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

    • ViewSharedData

      public ViewSharedData(ViewModel viewModel)
      The ViewSharedData function is a constructor for the ViewSharedData class. It takes in a ViewModel object and sets it to be the viewModel of this instance of ViewSharedData. It also initializes all other fields to null or false, depending on their type.
      Parameters:
      viewModel - viewModel Update the view
  • Method Details

    • getViewModel

      public ViewModel getViewModel()
      The getViewModel function returns the viewModel object.
      Returns:
      The viewModel
    • setPlayer

      public void setPlayer(Client player)
      The setPlayer function sets the player variable to a new Client object.
      Parameters:
      player - player Set the player variable to the client object that is passed in
    • getPlayer

      public Client getPlayer()
      The getPlayer function returns the player object.
      Returns:
      The player variable
    • setHostIp

      public void setHostIp(String hostIp)
      The setHostIp function sets the hostIp variable to a new value.
      Parameters:
      hostIp - hostIp Set the host ip address
    • getHostIp

      public String getHostIp()
      The getHostIp function returns the hostIp variable.
      Returns:
      The hostIp
    • setHost

      public void setHost(boolean host)
      The setHost function sets the isHost variable to true or false.
      Parameters:
      host - host Determine whether the user is a host or not
    • getHost

      public boolean getHost()
      The getHost function returns the boolean value of isHost.
      Returns:
      The value of the isHost variable
    • setCalculationServer

      public void setCalculationServer(MyServer calculationServer)
      The setCalculationServer function sets the calculationServer variable to a new MyServer object.
      Parameters:
      calculationServer - calculationServer Set the calculationServer variable in this class
    • getCalculationServer

      public MyServer getCalculationServer()
      The getCalculationServer function returns the calculationServer object.
      Returns:
      The calculationServer object
    • setPlayerName

      public void setPlayerName(String playerName)
      The setPlayerName function sets the player's name to a new value.
      Parameters:
      playerName - playerName Set the playerName variable
    • setHostPort

      public void setHostPort(int hostPort)
      The setHostPort function sets the hostPort variable to the value of its parameter.
      Parameters:
      hostPort - hostPort Set the hostPort variable
    • getHostPort

      public int getHostPort()
      The getHostPort function returns the port number of the host.
      Returns:
      The hostPort variable
    • setGameModelReceiver

      public void setGameModelReceiver(GameModelReceiver gameModelReceiver)
      The setGameModelReceiver function is used to set the gameModelReceiver variable.
      Parameters:
      gameModelReceiver - gameModelReceiver Set the gameModelReceiver variable to the parameter
    • update

      public void update(Observable o, Object arg)
      The update function is called by the Observable object when it has changed. The update function then updates the viewModel with a new model from the gameModelReceiver.
      Specified by:
      update in interface Observer
      Parameters:
      o - o Identify the observable object that has changed
      arg - arg Pass the updated model from the server to this client