Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AssessmentP2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
samuel.boulton
AssessmentP2
Commits
e52b3223
Commit
e52b3223
authored
Dec 03, 2018
by
samuelboulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comment added
parent
01df26df
Pipeline
#370
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
117 additions
and
3 deletions
+117
-3
AssessmentPartTwo.java
src/AssessmentPartTwo.java
+117
-3
No files found.
src/AssessmentPartTwo.java
View file @
e52b3223
...
...
@@ -13,7 +13,77 @@ public class AssessmentPartTwo {
// 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.
return
0
;
// Declaring the integer 'theWord' for the total score to be checked
int
theWord
=
0
;
// Looping round the length of the word
for
(
int
j
=
0
;
j
<
aWord
.
length
();
j
++)
{
// Putting the string into chars
char
parts
=
aWord
.
charAt
(
j
);
// Then checking if the chars match any of these characters
if
(
parts
==
'l'
||
parts
==
's'
||
parts
==
'u'
||
parts
==
'n'
||
parts
==
'r'
||
parts
==
't'
||
parts
==
'o'
||
parts
==
'a'
||
parts
==
'i'
||
parts
==
'e'
)
{
// If the character matches a char in the string it adds this score
theWord
+=
1
;
}
// Checking if the chars match any of these characters
if
(
parts
==
'g'
||
parts
==
'd'
)
{
// If the character matches a char in the string it adds this score
theWord
+=
2
;
}
// Checking if the chars match any of these characters
if
(
parts
==
'b'
||
parts
==
'c'
||
parts
==
'm'
||
parts
==
'p'
)
{
// If the character matches a char in the string it adds this score
theWord
+=
3
;
}
// Checking if the chars match any of these characters
if
(
parts
==
'f'
||
parts
==
'h'
||
parts
==
'v'
||
parts
==
'w'
||
parts
==
'y'
)
{
// If the character matches a char in the string it adds this score
theWord
+=
4
;
}
// Checking if the chars match any of these characters
if
(
parts
==
'k'
)
{
// If the character matches a char in the string it adds this score
theWord
+=
5
;
}
// Checking if the chars match any of these characters
if
(
parts
==
'j'
||
parts
==
'x'
)
{
// If the character matches a char in the string it adds this score
theWord
+=
8
;
}
// Checking if the chars match any of these characters
if
(
parts
==
'q'
||
parts
==
'z'
)
{
// If the character matches a char in the string it adds this score
theWord
+=
10
;
}
}
// return the total of 'theWord' to compare against the expectedScore
return
theWord
;
}
...
...
@@ -24,11 +94,55 @@ public class AssessmentPartTwo {
// is a valid password
// A password is valid if it is
// - between 8 and 16 characters long (inclusive)
// - 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
// - does not contain the phrases 'password' or 'passwd'
return
false
;
// Declaring each String for which is allowed and which isn't allowed
// .matches() is used to see if the password matches these statements
String
lowerCase
=
"(.*[a-z].*)"
;
String
upperCase
=
".*[A-Z].*"
;
String
numbers
=
".*[0-9].*"
;
String
symbols
=
".*[!�$%].*"
;
// if statement and contains() method to see if the password contains these phrases
if
(
password
.
contains
(
"passwd"
))
{
return
false
;
}
// if statement and contains() method to see if the password contains these phrases
if
(
password
.
contains
(
"password"
))
{
return
false
;
}
// if statement to make sure the length is between 16 and 8 letters long
if
(
password
.
length
()
>
16
||
password
.
length
()
<
8
)
{
return
false
;
}
// if statement to see if there is a lower cased letter in the password
if
(!
password
.
matches
(
lowerCase
))
{
return
false
;
}
// if statement to see if there is a upper cased letter in the password
if
(!
password
.
matches
(
upperCase
))
{
return
false
;
}
//hello
// if statement to see if there is a number in the password
if
(!
password
.
matches
(
numbers
))
{
return
false
;
}
if
(
password
.
contains
(
"!"
)
||
password
.
contains
(
"�"
)
||
password
.
contains
(
"$"
)
||
password
.
contains
(
"%"
))
{
return
true
;
}
else
{
return
true
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment