Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Assessment02
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
nouman.ashraf
Assessment02
Commits
e582fccf
Commit
e582fccf
authored
Jan 07, 2019
by
Dell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
01df26df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
112 additions
and
4 deletions
+112
-4
AssessmentPartTwo.java
src/AssessmentPartTwo.java
+112
-4
No files found.
src/AssessmentPartTwo.java
View file @
e582fccf
import
java.util.Scanner
;
public
class
AssessmentPartTwo
{
public
class
AssessmentPartTwo
{
...
@@ -12,13 +13,62 @@ public class AssessmentPartTwo {
...
@@ -12,13 +13,62 @@ 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
value
=
0
;
for
(
int
i
=
0
;
i
<
aWord
.
length
();
i
++)
// Loop according to the length of "aWord" size.
{
switch
(
aWord
.
charAt
(
i
))
// Switch statemant stars.
{
case
'a'
:
case
'e'
:
case
'i'
:
case
'o'
:
case
'n'
:
case
'r'
:
case
't'
:
case
'l'
:
case
's'
:
case
'u'
:
//It will add '1' into value,if you use any alphabets of these.
value
=
value
+
1
;
break
;
case
'd'
:
case
'g'
:
//It will add '2' into value,if you use any alphabets of these.
value
=
value
+
2
;
break
;
case
'b'
:
case
'c'
:
case
'm'
:
case
'p'
:
//It will add '3' into value,if you use any alphabets of these.
value
=
value
+
3
;
break
;
case
'f'
:
case
'h'
:
case
'v'
:
case
'w'
:
case
'y'
:
//It will add '4' into value,if you use any alphabets of these.
value
=
value
+
4
;
break
;
case
'k'
:
// '5' for k.
value
=
value
+
5
;
break
;
case
'j'
:
case
'x'
:
// //It will add '8' into value,if you use any alphabets of these.
value
=
value
+
8
;
break
;
case
'q'
:
case
'z'
:
//It will add '10' into value,if you use any alphabets of these.
value
=
value
+
10
;
break
;
default
:
System
.
out
.
println
(
"invalid INPUT"
);
//It will show this message if enter invalid input.
break
;
}
}
return
0
;
return
value
;
}
}
public
Boolean
passwordValidator
(
String
password
)
public
Boolean
passwordValidator
(
String
password
)
{
{
// 04 - Password Validator
// 04 - Password Validator
// Complete this method to validate that the String password
// Complete this method to validate that the String password
// is a valid password
// is a valid password
...
@@ -27,8 +77,66 @@ public class AssessmentPartTwo {
...
@@ -27,8 +77,66 @@ 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
pas
=
false
;
int
a
,
b
,
c
,
d
,
e
,
p
,
x
;
a
=
b
=
c
=
d
=
e
=
x
=
0
;
p
=
1
;
return
false
;
if
(
password
.
length
()<=
16
&&
password
.
length
()>=
8
)
//Condition that length should be between 8 and 16 characters long
{
a
=
1
;
//if codition is true then 'a=1'.
}
if
(
password
.
contains
(
"password"
)
||
password
.
contains
(
"passwd"
))
//If password contain "password" OR "passwd" then 'p=0'
{
p
=
0
;
}
for
(
int
i
=
0
;
i
<
password
.
length
();
i
++)
{
char
Chharacter
=
password
.
charAt
(
i
);
if
((
Chharacter
==
'!'
||
Chharacter
==
'£'
||
Chharacter
==
'$'
||
Chharacter
==
'%'
)||(
Chharacter
>=
'a'
&&
Chharacter
<=
'z'
)||(
Chharacter
>=
'A'
&&
Chharacter
<=
'Z'
)
||(
Chharacter
>=
'0'
&&
Chharacter
<=
'9'
))
// if these codition are true then 'x=1'
{
x
=
1
;
}
else
//otherwise 'x=0'
{
x
=
0
;
break
;
//and break the loop.
}
if
(
Chharacter
>=
'a'
&&
Chharacter
<=
'z'
)
//for lower case letters
{
c
=
1
;
}
if
(
Chharacter
>=
'A'
&&
Chharacter
<=
'Z'
)
//for upper case letters
{
d
=
1
;
}
if
((
Chharacter
>=
'0'
&&
Chharacter
<=
'9'
))
// for numeric values.
{
e
=
1
;
}
}
if
(
a
==
1
&&
c
==
1
&&
d
==
1
&&
e
==
1
&&
p
==
1
&&
x
==
1
)
// If the all previous conditions are true then "pas=true" and return pas.
{
pas
=
true
;
}
return
pas
;
}
}
}
}
\ No newline at end of file
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