Commit 7a688274 authored by tomun's avatar tomun

x

parent 01df26df
...@@ -12,8 +12,14 @@ public class AssessmentPartTwo { ...@@ -12,8 +12,14 @@ public class AssessmentPartTwo {
// https://en.wikipedia.org/wiki/Scrabble_letter_distributions // https://en.wikipedia.org/wiki/Scrabble_letter_distributions
// 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.
int score = 0;
return 0; int [] charScores = {1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10};
for(int i = 0; i < aWord.length(); i++)
{
int pos = Character.toUpperCase(aWord.charAt(i))-65;
score += charScores[pos];
}
return score;
} }
...@@ -27,7 +33,40 @@ public class AssessmentPartTwo { ...@@ -27,7 +33,40 @@ public class AssessmentPartTwo {
// - made up of letters (upper or lower), numbers, and the following characters !£$% // - made up of letters (upper or lower), numbers, and the following characters !£$%
// - 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'
Boolean valid = false;
Boolean upperLetter = false;
Boolean lowwerLetter = false;
Boolean number = false;
if ( password.toLowerCase().indexOf("passwd") != -1 | password.toLowerCase().indexOf("password") != -1)
{
return false;
}
if(password.length() > 7 && password.length() < 17)
{
for(int i = 0; i < password.length();i++)
{
if(password.charAt(i) <= 90 && password.charAt(i) >= 65)
{
upperLetter = true;
}
if(password.charAt(i) <= 122 && password.charAt(i) >= 97)
{
lowwerLetter = true;
}
if(password.charAt(i) <= 57 && password.charAt(i) >= 48)
{
number = true;
}
if(upperLetter && lowwerLetter && number)
{
return true;
}
}
}
return false; return false;
} }
......
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