Class CLI

java.lang.Object
it.polimi.ingsw.Client.CLI.CLI
All Implemented Interfaces:
Runnable

public class CLI extends Object implements Runnable
This class runs game's cli version and to do that it initializes client's view and runs 2 different threads: One for writing elements on CLI and send message to Server (CliWriter class) One for receiving responses from Server and update Client's view (ClientReader class)
  • Constructor Summary

    Constructors
    Constructor
    Description
    CLI()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private boolean
    isDecimal(String string)
    Check that a string represents a decimal number
    private boolean
    isIp(String string)
    used to verify that the string entered by the user is an ip address
    private static void
    OpenCLI(SocketWrapper socket, BufferedReader bufferedReader)
    Support method to initialize CliWriter and ClientReader threads, it also creates and initialize Client's view
    void
    run()
    Run Thread responsible for asking User which server wants to connect to

    Methods inherited from class java.lang.Object

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

    • CLI

      public CLI()
  • Method Details

    • run

      public void run()
      Run Thread responsible for asking User which server wants to connect to
      Specified by:
      run in interface Runnable
    • isIp

      private boolean isIp(String string)
      used to verify that the string entered by the user is an ip address
      Parameters:
      string - String typed by user
      Returns:
      true if the string is a valid ip address, false otherwise
    • OpenCLI

      private static void OpenCLI(SocketWrapper socket, BufferedReader bufferedReader)
      Support method to initialize CliWriter and ClientReader threads, it also creates and initialize Client's view
      Parameters:
      socket - SocketWrapper used to wrap the socket used from Client and Server
      bufferedReader - BufferedReader used to acquire ip address and port number will be used to acquire commands during the game
    • isDecimal

      private boolean isDecimal(String string)
      Check that a string represents a decimal number
      Parameters:
      string - The string to check
      Returns:
      true if string consists of only numbers without leading zeroes, false otherwise