Commit 8d7f07e8 authored by MaximumShast's avatar MaximumShast

Part 2 of 4 of the Assesment

parent 01df26df
...@@ -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.
return 0;
// setting up the int data type of the wordScore and setting its value to 0 since there is no input
int Word_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 (int i = 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
char letterScore = 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;
}
}
return Word_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'
return false;
//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) {
return false;
}
//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
boolean uppercaseCheck = password.equals(password.toLowerCase());
//Password will be checked to see if its all Upper case if so the boolean will be set to true
boolean lowercaseCheck = password.equals(password.toUpperCase());
//This Section states that if UpperCaseCheck Or LowercaseCheck is True then the program will return false
if(uppercaseCheck || lowercaseCheck) {
return false;
}
//This Section creates the string passwd which contains "passwd" to be used as the example
String passwd = "passwd";
//This section converts password to lower case and says that if the string password is equal to passwd or contains passwd then it will return false
if ( password.toLowerCase().indexOf(passwd.toLowerCase()) != -1 ) {
return false;
}
//This Section creates the string passWord which contains "password"
String passWord = "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
if ( password.toLowerCase().indexOf(passWord.toLowerCase()) != -1 ) {
return false;
}
}
//If none of these conditions have been triggered the program will return true
return true;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment