user.java

来自「JAVA Servlet2.3外文书籍源码」· Java 代码 · 共 64 行

JAVA
64
字号
package forum;

import java.util.*;

/**
 * Represents a user in the discussion forum.
 *
 * @author    Simon Brown
 */
public class User {

  /** the user id */
  private String id;

  /** the password */
  private String password;

  /**
   * Creates a new user with the specified id and password.
   *
   * @param id        the user id
   * @param password  the password
   */
  User(String id, String password) {
    this.id = id;
    this.password = password;
  }

  /**
   * Getter for the user id property.
   *
   * @return  the user id
   */
  public String getId() {
    return this.id;
  }

  /**
   * Getter for the password property.
   *
   * @return  the password
   */
  String getPassword() {
    return this.password;
  }

  /**
   * Determines whether this object is the same as another.
   *
   * @param o   the Object to test against
   * @return  true if the specified object is equal to this one,
   *          false otherwise
   */
  public boolean equals(Object o) {
    if (o instanceof User) {
      User u = (User)o;

      return getId().equals(u.getId());
    } else {
      return false;
    }
  }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?