HWOJ密码验证合格程序 (为什么错了,搞不懂。。)

package snippet;
import java.util.*;
public class Snippet {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String str = sc.next();
            boolean bol1=isNotRepeatString(str);
            boolean bol2=isLength(str);
            boolean bol3=isInclude(str);
            if(bol1&&bol2&&bol3) {System.out.println("OK");}
            else {System.out.println("NG");}
        }
        sc.close();
    }
    public static boolean isNotRepeatString(String str){
        int len = str.length();
        for (int i = 0; i < len; i++){
            for (int j = i + 1; j < len-3; j++){
                if (str.charAt(i) == str.charAt(j) && str.charAt(i+1) == str.charAt(j+1) && str.charAt(i+2) == str.charAt(j+2)){
                    return false;
                }
            }
        }
        return true;
    }
    public static boolean isLength(String str){
        if(str.length()>8) {return true;}
        else {return false;}
    }
    public static boolean isInclude(String str){
        boolean b1 = false;
        boolean b2 = false;
        boolean b3 = false;
        boolean b4 = false;
        for(int i=0;i='a'&&str.charAt(i)<='z'){
                b1 = true;
            }
            if(str.charAt(i)>='A'&&str.charAt(i)<='Z'){
                b2 = true;
            }
            if(str.charAt(i)>='0'&&str.charAt(i)<='9'){
                b3 = true;
            }
            if(!(str.charAt(i)>='A'&&str.charAt(i)<='Z')&&!(str.charAt(i)>='0'&&str.charAt(i)<='9')&&!(str.charAt(i)>='a'&&str.charAt(i)<='z')){
                b4 = true;
            }
        }
        if((b1 && b2 && b3 && b4) || (b1 && b2 && b3) || (b1 && b2 && b4) || (b1 && b3 && b4) || (b2 && b3 && b4)){
            return true;
        }else{
            return false;
        }
        
    }
}

你可能感兴趣的:(HWOJ密码验证合格程序 (为什么错了,搞不懂。。))