Class BookScrabbleHandler

java.lang.Object
model.logic.server.dictionary.BookScrabbleHandler
All Implemented Interfaces:
ClientHandler

public class BookScrabbleHandler extends Object implements ClientHandler
  • Constructor Details

    • BookScrabbleHandler

      public BookScrabbleHandler()
      The BookScrabbleHandler function takes in a Book object and returns an integer value. The function calculates the scrabble score of the book by adding up all the individual word scores.
  • Method Details

    • handleClient

      public void handleClient(InputStream inFromClient, OutputStream outToClient)
      The handleClient function is called by the server when a client connects to it. The function takes two arguments: an InputStream and an OutputStream, which are used to communicate with the client. The function reads from the input stream until it receives a line of text that begins with either 'Q' or 'C'. If the line begins with 'Q', then this indicates that we should query our dictionary for whether a word exists in it. If so, we write "true" back to the output stream; otherwise, we write "false". Note that if there is any error reading from/
      Specified by:
      handleClient in interface ClientHandler
      Parameters:
      inFromClient - inFromClient Read the input from the client
      outToClient - outToClient Write the response to the client
    • close

      public void close()
      The close function is used to close the connection between the client and server. This function is called when a user logs out of their account or closes the program.
      Specified by:
      close in interface ClientHandler