user3.java

来自「beginJsp2.0外文书籍源代码」· Java 代码 · 共 48 行

JAVA
48
字号
package com.wrox.except;

public class User3
{

  private String username;
  private String password;

  public User3()
  {
  }

  public void setUsername(String username)
  {
    this.username = username;
  }

  public String getUsername()
  {
    return this.username;
  }

  public void setPassword(String password)
  {
    this.password = password;
  }

  public void validate() throws UserException, Exception
  {
    if(this.username == null)
    {
      throw new UserException("UserName must be supplied !!");
    }
    if(this.password == null)
    {
      throw new UserException("Password must be supplied !!",
                              this.username);
    }    
    if (!(this.username.equals("Dougal")
       && this.password.equals("roundabout")))
    {
      Exception trouble = new Exception("Couldn't validate your"
                                      + " password!");
      throw trouble;
    }
  }
}

⌨️ 快捷键说明

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