Package client
Class User
java.lang.Object
client.User
User - Represents a chat user.
Stores user information for identifying message senders.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares this user to another object for equality.getName()Returns the display name of the user.inthashCode()Generates a hash code for this user based on their name.voidSets or updates the display name of the user.toString()Returns a string representation of the user, which is their name.
-
Constructor Details
-
User
Constructs a new User with the specified name.- Parameters:
name- The display name of the user.
-
-
Method Details
-
getName
Returns the display name of the user.- Returns:
- The user's name as a String.
-
setName
Sets or updates the display name of the user.- Parameters:
name- The new name to assign to this user.
-
toString
Returns a string representation of the user, which is their name. -
equals
Compares this user to another object for equality. Two users are considered equal if they share the same name. -
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.
-