Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Programming-01-Assesment-03
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
ben.coxford
Programming-01-Assesment-03
Commits
51cb1380
Commit
51cb1380
authored
Dec 28, 2018
by
Ben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Third Part Complete
parent
e56f0d16
Pipeline
#554
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
2 deletions
+49
-2
AssessmentPartThree.java
src/AssessmentPartThree.java
+49
-2
No files found.
src/AssessmentPartThree.java
View file @
51cb1380
...
...
@@ -17,7 +17,47 @@ public class AssessmentPartThree {
// Lower case characters remain lower case, upper case remain upper case
// Any other characters are returned unchanged
return
'a'
;
if
(
Character
.
isDigit
(
theChar
)
||
Character
.
isWhitespace
(
theChar
))
{
return
theChar
;
}
char
[]
letters
=
{
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
,
'i'
,
'j'
,
'k'
,
'l'
,
'm'
,
'n'
,
'o'
,
'p'
,
'q'
,
'r'
,
's'
,
't'
,
'u'
,
'v'
,
'w'
,
'x'
,
'y'
,
'z'
};
if
(
Character
.
toUpperCase
(
theChar
)
==
theChar
)
{
for
(
int
i
=
0
;
i
<
letters
.
length
;
i
++)
{
letters
[
i
]
=
Character
.
toUpperCase
(
letters
[
i
]);
}
}
int
index
=
-
1
;
for
(
int
i
=
0
;
i
<
letters
.
length
;
i
++)
{
if
(
theChar
==
letters
[
i
])
{
index
=
i
;
}
}
if
(
index
!=
-
1
)
{
if
(((
index
+
theOffset
)
<=
letters
.
length
)
&&
(((
index
+
theOffset
)
>=
0
)))
{
index
=
index
+
theOffset
;
}
else
if
((
index
+
theOffset
)
<
0
)
{
index
=
letters
.
length
+
(
index
+
theOffset
);
}
else
{
index
=
(
index
+
theOffset
)
-
letters
.
length
;
}
}
if
(
index
==
-
1
)
{
return
theChar
;
}
else
{
return
letters
[
index
];
}
}
public
String
encryptedString
(
String
theMessage
,
int
theOffset
)
...
...
@@ -25,8 +65,15 @@ public class AssessmentPartThree {
// 06 - encryptedMessage
// Complete this method so that it uses encryptedCharacter to
// return the encrypted version of theMessage using theOffset
String
message
=
""
;
for
(
int
i
=
0
;
i
<
theMessage
.
length
();
i
++)
{
char
current
=
theMessage
.
charAt
(
i
);
char
newChar
=
enryptedCharacter
(
current
,
theOffset
);
message
=
message
+
newChar
;
}
return
"Encryptred message"
;
return
message
;
}
}
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