Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
asignment
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
thomas.unsworth
asignment
Commits
7a688274
Commit
7a688274
authored
Dec 28, 2018
by
tomun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
01df26df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
3 deletions
+42
-3
AssessmentPartTwo.java
src/AssessmentPartTwo.java
+42
-3
No files found.
src/AssessmentPartTwo.java
View file @
7a688274
...
...
@@ -12,8 +12,14 @@ public class AssessmentPartTwo {
// 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
// a way of identifying each letter in the word.
return
0
;
int
score
=
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 {
// - 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'
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
;
}
...
...
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