Package client

Class Chat

java.lang.Object
client.Chat

public class Chat extends Object
This class acts as a data container for the chat's identity, the history of messages sent, and the list of participating users.
  • Constructor Details

    • Chat

      public Chat(String chatName)
      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

      public String getChatName()
      Gets the name of the chat room.
      Returns:
      The chat name as a String.
    • getMessages

      public ArrayList<Message> getMessages()
      Gets the list of all messages recorded in this chat.
      Returns:
      An ArrayList containing the Message objects.
    • getUsers

      public ArrayList<User> getUsers()
      Gets the list of users associated with this chat.
      Returns:
      An ArrayList containing the User objects.
    • addMessage

      public void addMessage(Message message)
      Appends a new message to the chat history.
      Parameters:
      message - The Message to be added.
    • addUser

      public void addUser(User user)
      Adds a user to the list of participants in this chat.
      Parameters:
      user - The User to be added.
    • toString

      public String toString()
      Returns a string representation of the chat, which is its name.
      Overrides:
      toString in class Object
      Returns:
      The name of the chat.