码迷,mamicode.com
首页 > 编程语言 > 详细

java第六次作业

时间:2017-03-31 16:59:39      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:image   错误   sys   stat   ges   login   span   用户名   equals   

class Check{
 public boolean validate(String name,String password){
  if(name.equals("huangjiashuai")&&password.equals("hjs")){
   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.validate(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);
  }
 }
}
public class LoginDemo02{
 public static void main(String args[]){
  Operate oper = new Operate(args);
  System.out.println(oper.login());
 }
}

技术分享

java第六次作业

标签:image   错误   sys   stat   ges   login   span   用户名   equals   

原文地址:http://www.cnblogs.com/azkahb/p/6651848.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!