Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
programming 01 part two
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
joseph.jackson1
programming 01 part two
Commits
c8fa3721
Commit
c8fa3721
authored
Jan 29, 2019
by
Scourier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
assessment part two commit
parent
01df26df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
3 deletions
+54
-3
AssessmentPartTwo.java
src/AssessmentPartTwo.java
+54
-3
No files found.
src/AssessmentPartTwo.java
View file @
c8fa3721
...
@@ -13,7 +13,41 @@ public class AssessmentPartTwo {
...
@@ -13,7 +13,41 @@ 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
;
int
score
=
0
;
// Here I'll add up all the points to later return the value of the word
int
a
=
1
;
int
b
=
2
;
int
c
=
3
;
int
d
=
4
;
int
e
=
5
;
int
f
=
8
;
int
g
=
10
;
// these ints are used to assign a value to each letter
for
(
int
i
=
0
;
i
<
aWord
.
length
();
i
++){
// goes through the word 1 letter at a time until it's gone through every letter
char
letter
=
aWord
.
charAt
(
i
);
// assigns a variable to the current index of the word
if
((
letter
==
'a'
)
||
(
letter
==
'e'
)
||
(
letter
==
'i'
)
||
(
letter
==
'o'
)
||
(
letter
==
'n'
)
||
(
letter
==
'r'
)
||
(
letter
==
't'
)
||
(
letter
==
'l'
)
||
(
letter
==
's'
)
||
(
letter
==
'u'
)
){
score
=
score
+
a
;
}
// checks if any of these letters matches the current index and if so adds the correct points to the total score
else
if
((
letter
==
'd'
)
||
(
letter
==
'g'
)
)
{
score
=
score
+
b
;
}
// checks if any of these letters matches the current index and if so adds the correct points to the total score
else
if
((
letter
==
'b'
)
||
(
letter
==
'c'
)
||
(
letter
==
'm'
)
||
(
letter
==
'p'
))
{
score
=
score
+
c
;
}
// checks if any of these letters matches the current index and if so adds the correct points to the total score
else
if
((
letter
==
'f'
)
||
(
letter
==
'h'
)
||
(
letter
==
'v'
)
||
(
letter
==
'w'
)
||
(
letter
==
'y'
))
{
score
=
score
+
d
;
}
// checks if any of these letters matches the current index and if so adds the correct points to the total score
else
if
(
letter
==
'k'
)
{
score
=
score
+
e
;
}
// checks if any of these letters matches the current index and if so adds the correct points to the total score
else
if
((
letter
==
'j'
)
||
(
letter
==
'x'
))
{
score
=
score
+
f
;
}
// checks if any of these letters matches the current index and if so adds the correct points to the total score
else
if
((
letter
==
'q'
)
||
(
letter
==
'z'
))
{
score
=
score
+
g
;
}
// checks if any of these letters matches the current index and if so adds the correct points to the total score
}
return
score
;
}
}
...
@@ -28,7 +62,24 @@ public class AssessmentPartTwo {
...
@@ -28,7 +62,24 @@ 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
;
}
if
(
password
.
contains
(
"passwd"
)
||
(
password
.
contains
(
"password"
)
||
(
password
.
contains
(
"PASSWORD"
)))){
return
false
;
}
else
if
(
password
.
matches
(
"(?=.+\\d)(?=.+[a-z])(?=.+[A-Z])(.{8,16})$"
))
{
return
true
;
}
else
{
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