user2.java

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

JAVA
47
字号
package com.wrox.except;

import java.io.IOException;

public class User2
{

  private String username;
  private String password;

  public User2()
  {
  }

  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 IOException, Exception
  {
    if(this.username == null || this.password == null)
    {
      IOException ioex = new IOException("You must supply a username"
                                       + " and password!!");
      throw ioex;
    }
    if (!(this.username.equals("Casey")
       && this.password.equals("Kochmer")))
    {
      Exception trouble = new Exception("Couldn't validate your"
                                      + " password!");
      throw trouble;
    }
  }
}

⌨️ 快捷键说明

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