Class ConsoleClient

java.lang.Object
sources.client.ConsoleClient
All Implemented Interfaces:
Client

public class ConsoleClient extends Object implements Client
The ConsoleClient class implements the Client interface and is responsible for interacting with the user through the console. It initializes the Invoker and Receiver, reads user input, executes commands and handles exceptions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) Invoker
     
    (package private) Receiver
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Executes a script file containing a list of commands.
    void
    Terminates the program.
    void
    Displays a list of available commands and their descriptions to the user.
    void
    Displays a list of previously executed commands to the user.
    void
    Main method of the ConsoleClient class.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ConsoleClient

      public ConsoleClient()
  • Method Details

    • main

      public void main()
      Main method of the ConsoleClient class. Initializes the Invoker, Receiver and Reader and starts an interactive loop to read user input and execute commands.
    • help

      public void help()
      Displays a list of available commands and their descriptions to the user.
      Specified by:
      help in interface Client
    • exit

      public void exit()
      Terminates the program.
      Specified by:
      exit in interface Client
    • history

      public void history()
      Displays a list of previously executed commands to the user.
      Specified by:
      history in interface Client
    • executeScript

      public void executeScript(String path) throws CustomIOException
      Executes a script file containing a list of commands.
      Specified by:
      executeScript in interface Client
      Parameters:
      path - the path of the script file to execute
      Throws:
      CustomIOException - if there is an error reading the script file