Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Programming 01
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
Commits
63fd1950
Commit
63fd1950
authored
Jan 29, 2019
by
joseph.jackson1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete AssessmentPartTwo.java
parent
3623904b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
85 deletions
+0
-85
AssessmentPartTwo.java
src/AssessmentPartTwo.java
+0
-85
No files found.
src/AssessmentPartTwo.java
deleted
100644 → 0
View file @
3623904b
public
class
AssessmentPartTwo
{
public
int
scrabbleScore
(
String
aWord
)
{
// 03 -Scrabble Score
// Complete this method so that it returns the scrabble score for the word in aWord
// In scrabble each letter is worth a number of points and each word is worth the
// sum of the scores of the letters in it. For this assignment we will ignore
// double/treble letter/word bonuses.
// The English language points per letter can be found at
// 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.
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
;
}
public
Boolean
passwordValidator
(
String
password
)
{
// 04 - Password Validator
// Complete this method to validate that the String password
// 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 !£$%
// - has at least one lower case letter, one upper case letter and a number
// - does not contain the phrases 'password' or 'passwd'
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