首页 > 代码库 > 简单的系统登陆

简单的系统登陆

//  简答的系统登陆,固定的name、password.

public class HelloWorldapp {

  public static void main(String args[]){
    Operate oper = new Operate(args);
    System.out.print(oper.Login());
  }
}
  class Check{
    public boolean valldate(String name,String password){
      if(name.equals("lixinghua") && password.equals("mldn")){
        return true;
      }
      else{
        return false;
      }
    }
  }

  class Operate{
    private String info[];
    public Operate(String info[]){
      this.info = info;
    }

    public String Login(){
      Check check = new Check();
      this.isExit();
      String name = this.info[0];
      String password = this.info[1];
      String str = null;
      if(check.valldate(name, password)){
        str = "欢迎" + name + "光临!";
      }
      else{
        str = "错误的用户名和密码";
      }
      return str;
  }
  public void isExit(){
    if(this.info.length != 2){
      System.out.println("输入的参数格式不对,系统退出!");
      System.out.println("格式 java LoginDemo02");
      System.exit(1);
    }
  }
}

简单的系统登陆