For checking one upper case here is the method:
private boolean containsUpperCase(String word) {
int ndx;
char ch;
boolean t=false;
char[] letter=word.toCharArray();
for(ndx = 0; ndx < word.length(); ndx++) {
ch = letter[ndx];
if (ch <='Z'&&ch>='A') {
t=true;
}
}
return t;
}
For lower case:
private boolean containsLowerCase(String word) {
int ndx;
char ch;
boolean t=false;
char[] letter=word.toCharArray();
for(ndx = 0; ndx < word.length(); ndx++) {
ch = letter[ndx];
if (ch <='a'+32&&ch>='z'-32) {//the same as ch>='a' && ch<='z'
t=true;
}
}
return t;
}
And for at least one appearance of digit in the String:
private boolean isDigit(String word) {
int ndx;
char ch;
boolean t=false;
char[] letter=word.toCharArray();
for(ndx = 0; ndx < word.length(); ndx++) {
ch = letter[ndx];
if (ch <='9'&&ch>='0') {
t=true;
}
}
return t;
}
So as you see buddy,the main work for checking letters in the String is with the ASCII table values.So in order to complete your isValide() method we di the following:
private static boolean isValid(String psWord)
{
boolean goodSoFar = true;
int index = 0;
if (psWord.length() < 6)//at least 6 characters
goodSoFar = false;
return goodSoFar;
if(containsUpperCase(psWord)==false)
goodSoFar=false;
return goodSoFar;
if(containsLowerCase(psWord)==false)
goodSoFar=false;
return goodSoFar;
if(isDigit(psWord)==false)
goodSoFar=false;
return goodSoFar;
return goodSoFar;
}