Package org.cis1200
Class Command
java.lang.Object
org.cis1200.Command
- Direct Known Subclasses:
CreateCommand
,InviteCommand
,JoinCommand
,KickCommand
,LeaveCommand
,MessageCommand
,NicknameCommand
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compare two commands Returnstrue
if twoCommand
s are equal; that is, if they produce the same string representation.int
Get the userId of the client who issued theCommand
.abstract ResponseSet
updateServerModel
(ServerModel model) Process the command and update the server model accordingly.
-
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 theCommand
.- Returns:
- The userId of the client who issued this command
-
updateServerModel
Process the command and update the server model accordingly.- Parameters:
model
- An instance of theServerModel
class which represents the current state of the server.- Returns:
- A
ResponseSet
object, informing clients about changes resulting from the command.
-
equals
Compare two commands Returnstrue
if twoCommand
s are equal; that is, if they produce the same string representation. Note that all subclasses ofCommand
must override theirtoString
method appropriately for this definition to make sense. (We have done this for you below.)
-