Package org.cis1200

Class Command

java.lang.Object
org.cis1200.Command
Direct Known Subclasses:
CreateCommand, InviteCommand, JoinCommand, KickCommand, LeaveCommand, MessageCommand, NicknameCommand

public abstract class Command extends Object
A Command represents a string sent from a client to the server, after parsing it into a more convenient form. Each concrete subclass of the Command abstract class corresponds to a different sort of command that can be issued by a client. In addition to the various getter methods, all subclasses of this class override the updateServerModel method that calls the appropriate method of the ServerModel class to process the command. You do not need to modify this file, but you should read through it to make sure that you understand the various commands that the server needs to process and the data fields that are included in each of these command objects.
  • Constructor Details

    • Command

      Command(Integer senderId)
      Constructor; initializes the private fields of the object.
      Parameters:
      senderId - of this command
  • Method Details

    • getSenderId

      public int getSenderId()
      Get the userId of the client who issued the Command.
      Returns:
      The userId of the client who issued this command
    • updateServerModel

      public abstract ResponseSet updateServerModel(ServerModel model)
      Process the command and update the server model accordingly.
      Parameters:
      model - An instance of the ServerModel class which represents the current state of the server.
      Returns:
      A ResponseSet object, informing clients about changes resulting from the command.
    • equals

      public boolean equals(Object o)
      Compare two commands Returns true if two Commands are equal; that is, if they produce the same string representation. Note that all subclasses of Command must override their toString method appropriately for this definition to make sense. (We have done this for you below.)
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare with this for equality
      Returns:
      true iff both objects are non-null and equal to each other