Package client
Class Chat
java.lang.Object
client.Chat
This class acts as a data container for the chat's identity,
the history of messages sent, and the list of participating users.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMessage(Message message) Appends a new message to the chat history.voidAdds a user to the list of participants in this chat.Gets the name of the chat room.Gets the list of all messages recorded in this chat.getUsers()Gets the list of users associated with this chat.toString()Returns a string representation of the chat, which is its name.
-
Constructor Details
-
Chat
Constructs a new Chat instance with a specific name. Initializes empty lists for both messages and users.- Parameters:
chatName- The name to be assigned to this chat room.
-
-
Method Details
-
getChatName
Gets the name of the chat room.- Returns:
- The chat name as a String.
-
getMessages
Gets the list of all messages recorded in this chat.- Returns:
- An ArrayList containing the Message objects.
-
getUsers
Gets the list of users associated with this chat.- Returns:
- An ArrayList containing the User objects.
-
addMessage
Appends a new message to the chat history.- Parameters:
message- The Message to be added.
-
addUser
Adds a user to the list of participants in this chat.- Parameters:
user- The User to be added.
-
toString
Returns a string representation of the chat, which is its name.
-