面向对象_方法 判断

package FacePro;

import java.util.Scanner;

public class StarSMSTest {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner input = new Scanner(System.in);
        StarSMS sms = new StarSMS();
        String name;
        String pwd;
        String yOrNo = "n";
        boolean success = false;
        do{    
            yOrNo = "n";
            System.out.println("请输入名称:");
            name = input.next();
            System.out.println("请输入密码:");
            pwd = input.next();
            boolean result = sms.scanner(name, pwd);
            if(!result){
                System.out.println("用户信息不匹配,是否继续");
                yOrNo = input.next();
                
            }else{
                System.out.println("登录成功");
                success = true;
            }
        }while (yOrNo.equalsIgnoreCase("y"));
        if(!success){
            System.out.println("系统关闭,谢谢使用!");
        }
        input.close();
    }

}
package FacePro;

public class StarSMS {
    public boolean scanner(String name,String pwd){
        boolean result;
        if(!name.equals("bird")||!pwd.equals("0000")){
            result = false;
        }else{
            result = true;
        }
        return result;
    }
}

 

posted @ 2016-08-03 15:42  me丶不是好人  阅读(141)  评论(0编辑  收藏  举报