Package client

Class User

java.lang.Object
client.User

public class User extends Object
User - Represents a chat user. Stores user information for identifying message senders.
  • Constructor Summary

    Constructors
    Constructor
    Description
    User(String name)
    Constructs a new User with the specified name.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Compares this user to another object for equality.
    Returns the display name of the user.
    int
    Generates a hash code for this user based on their name.
    void
    Sets or updates the display name of the user.
    Returns a string representation of the user, which is their name.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • User

      public User(String name)
      Constructs a new User with the specified name.
      Parameters:
      name - The display name of the user.
  • Method Details

    • getName

      public String getName()
      Returns the display name of the user.
      Returns:
      The user's name as a String.
    • setName

      public void setName(String name)
      Sets or updates the display name of the user.
      Parameters:
      name - The new name to assign to this user.
    • toString

      public String toString()
      Returns a string representation of the user, which is their name.
      Overrides:
      toString in class Object
      Returns:
      The users name.
    • equals

      public boolean equals(Object obj)
      Compares this user to another object for equality. Two users are considered equal if they share the same name.
      Overrides:
      equals in class Object
      Parameters:
      obj - The object to compare with this User.
      Returns:
      true if the names are identical; false otherwise.
    • hashCode

      public int hashCode()
      Generates a hash code for this user based on their name. This ensures that Users can be stored and retrieved correctly.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code of the user's name.