@@ -13,7 +13,88 @@ public class AssessmentPartTwo {
...
@@ -13,7 +13,88 @@ public class AssessmentPartTwo {
// You will need to come up with a way of connecting each letter to its score and
// You will need to come up with a way of connecting each letter to its score and
// a way of identifying each letter in the word.
// a way of identifying each letter in the word.
return0;
// setting up the int data type of the wordScore and setting its value to 0 since there is no input
intWord_score=0;
// setting up the int data type variable i to also equal 0
// as well as stating that every time i is less than aWords length it will convert it to lower case and increment it by 1
for(inti=0;i<aWord.length();i++){
aWord=aWord.toLowerCase();
//The program then creates the data type char called letterScore and sets it to equal the char at the position of i un aWord
// i's position us determined by what the equivalent of it is on its run through the code
charletterScore=aWord.charAt(i);
switch(letterScore){
case'a':
case'e':
case'i':
case'o':
case'u':
// Separating vowels and consonant for ease of use
case'l':
case'n':
case'r':
case's':
case't':
//If letterScore is equal yo any of the letters above then 1 will be added to the int wordScore
Word_score+=1;
//The break the code from running it into the segments below
break;
case'd':
case'g':
//If letterScore is equal to any of the letters above then 2 will be added to the int wordScore
Word_score+=2;
break;
case'b':
case'c':
case'm':
case'p':
//If letterScore is equal to any of the letters above 3 will be added to the in wordScore
Word_score+=3;
break;
case'f':
case'h':
case'v':
case'w':
case'y':
// If letterScore is equal to any of the letters above 4 will be andded to the int wordScore
Word_score+=4;
break;
case'k':
// If letterScore is equal to any of the letters above 5 will be added to the int wordScore
Word_score+=5;
break;
case'j':
case'x':
// If letterScore is equal to any of the letters above 8 will be added to the in wordScore
Word_score+=8;
break;
case'q':
case'z':
// If letterScore is equal to any of the letters above 10 will be added to the int wordScore
Word_score+=10;
default:break;
}
}
returnWord_score;
}
}
...
@@ -28,7 +109,50 @@ public class AssessmentPartTwo {
...
@@ -28,7 +109,50 @@ public class AssessmentPartTwo {
// - has at least one lower case letter, one upper case letter and a number
// - has at least one lower case letter, one upper case letter and a number
// - does not contain the phrases 'password' or 'passwd'
// - does not contain the phrases 'password' or 'passwd'
returnfalse;
//This section of the code is designed to make sure the password length is between 8 and 16 characters long other wise it will be flagged as a false boolean.
if(password.length()<8||password.length()>16){
returnfalse;
}
//This section of the code runs if password is within the parameters of 8 and 16 characters
else{
//This section of code creates two different booleans called UpperCaseCheck and LowerCaseCheck
//Password will be checked to see if it's in all lower case if so the boolean will be set to true
//This Section creates the string passWord which contains "password"
StringpassWord="password";
//This section converts password to lower case and says that if the string password is equal to passWord or contains passWord then it will return false