Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Assesment part 2
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
romain.vasseur
Assesment part 2
Commits
83770f73
Commit
83770f73
authored
Dec 03, 2018
by
Romain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
part two update
parent
01df26df
Pipeline
#378
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
116 additions
and
4 deletions
+116
-4
AssessmentPartTwo.java
src/AssessmentPartTwo.java
+116
-4
No files found.
src/AssessmentPartTwo.java
View file @
83770f73
public
class
AssessmentPartTwo
{
public
int
scrabbleScore
(
String
aWord
)
{
// 03 -Scrabble Score
...
...
@@ -13,7 +13,51 @@ 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
;
int
total
=
0
;
int
point
=
0
;
boolean
to
=
false
;
for
(
int
j
=
0
;
j
<
aWord
.
length
();
j
++)
{
switch
(
aWord
.
charAt
(
j
))
{
case
'a'
:
case
'o'
:
case
'e'
:
case
'i'
:
case
'n'
:
case
'r'
:
case
't'
:
case
'l'
:
case
's'
:
case
'u'
:
point
=
1
;
total
=
total
+
point
;
break
;
case
'd'
:
case
'g'
:
point
=
2
;
total
=
total
+
point
;
break
;
case
'b'
:
case
'c'
:
case
'm'
:
case
'p'
:
point
=
3
;
total
=
total
+
point
;
break
;
case
'f'
:
case
'h'
:
case
'v'
:
case
'w'
:
case
'y'
:
point
=
4
;
total
=
total
+
point
;
break
;
case
'k'
:
point
=
5
;
total
=
total
+
point
;
break
;
case
'j'
:
case
'x'
:
point
=
8
;
total
=
total
+
point
;
break
;
case
'q'
:
case
'z'
:
point
=
10
;
total
=
total
+
point
;
break
;
default
:
to
=
true
;
break
;
}
}
if
(
to
==
false
)
{
System
.
out
.
print
(
total
);
}
else
{
System
.
out
.
println
(
"Error"
);
}
return
total
;
}
...
...
@@ -24,11 +68,79 @@ 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'
boolean
pass
=
false
;
boolean
valid
=
false
;
boolean
lowerCase
=
false
;
boolean
upperCase
=
false
;
boolean
number
=
false
;
boolean
test
=
false
;
boolean
specialChar
=
false
;
boolean
error
=
false
;
if
(
password
.
length
()>=
8
&
password
.
length
()<=
16
)
{
valid
=
true
;
}
else
{
valid
=
false
;
}
for
(
int
i
=
0
;
i
<
password
.
length
();
i
++)
{
if
(
Character
.
isLowerCase
(
password
.
charAt
(
i
))==
true
)
{
lowerCase
=
true
;
}
else
{
if
(
Character
.
isUpperCase
(
password
.
charAt
(
i
))==
true
)
{
upperCase
=
true
;
}
else
{
if
(
Character
.
isDigit
(
password
.
charAt
(
i
))==
true
)
{
number
=
true
;
}
else
{
switch
(
password
.
charAt
(
i
))
{
case
'!'
:
case
'%'
:
case
'$'
:
case
'£'
:
test
=
true
;
specialChar
=
true
;
error
=
false
;
break
;
default
:
test
=
false
;
error
=
true
;
break
;
}
}
}
}
}
if
(
password
.
toLowerCase
().
contains
(
"password"
)|
password
.
toLowerCase
().
contains
(
"passwd"
))
{
valid
=
false
;
}
if
(
lowerCase
==
true
&
upperCase
==
true
&
valid
==
true
&
number
==
true
&
error
==
false
)
{
pass
=
true
;
}
else
{
pass
=
false
;
}
return
false
;
return
pass
;
}
}
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