Package it.polimi.ingsw.Client.CLI
Class CLI
java.lang.Object
it.polimi.ingsw.Client.CLI.CLI
- All Implemented Interfaces:
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
-
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
Check that a string represents a decimal numberprivate boolean
used to verify that the string entered by the user is an ip addressprivate static void
OpenCLI
(SocketWrapper socket, BufferedReader bufferedReader) Support method to initialize CliWriter and ClientReader threads, it also creates and initialize Client's viewvoid
run()
Run Thread responsible for asking User which server wants to connect to
-
Constructor Details
-
CLI
public CLI()
-
-
Method Details
-
run
public void run()Run Thread responsible for asking User which server wants to connect to -
isIp
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
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 ServerbufferedReader
- BufferedReader used to acquire ip address and port number will be used to acquire commands during the game
-
isDecimal
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
-