Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Assessment 3
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
daniel.parker
Assessment 3
Commits
a7175211
Commit
a7175211
authored
Dec 03, 2018
by
daniel.parker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial.
parent
e56f0d16
Pipeline
#384
canceled with stages
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
12 deletions
+38
-12
AssessmentPartThree.java
src/AssessmentPartThree.java
+38
-12
No files found.
src/AssessmentPartThree.java
View file @
a7175211
...
@@ -8,8 +8,27 @@ public class AssessmentPartThree {
...
@@ -8,8 +8,27 @@ public class AssessmentPartThree {
// - so a becomes b, b becomes c, etc
// - so a becomes b, b becomes c, etc
// If a value of -2 is chosen a becomes y, b becomes z and so on
// If a value of -2 is chosen a becomes y, b becomes z and so on
public
char
enryptedCharacter
(
char
theChar
,
int
theOffset
)
public
char
enryptedCharacter
(
char
theChar
,
int
theOffset
)
{
{
char
returnChar
=
theChar
;
int
x
=
0
;
String
alphabet
=
"abcdefghijklmnopqrstuvwxyz"
;
if
(
Character
.
isUpperCase
(
theChar
))
{
alphabet
=
alphabet
.
toUpperCase
();
}
for
(
int
i
=
0
;
i
<
alphabet
.
length
();
i
++)
{
char
character
=
alphabet
.
charAt
(
i
);
if
(
character
==
theChar
)
{
x
=
i
+
theOffset
;
if
(
x
>
26
)
{
x
=
(
x
-
26
);
}
if
(
x
<
0
)
{
x
=
(
x
+
26
);
}
returnChar
=
alphabet
.
charAt
(
x
);
}
}
// 05 - encryptedCharacter
// 05 - encryptedCharacter
// Complete this method so that it returns the encrypted character for
// Complete this method so that it returns the encrypted character for
// theChar when and offset of theOffset is used
// theChar when and offset of theOffset is used
...
@@ -17,16 +36,23 @@ public class AssessmentPartThree {
...
@@ -17,16 +36,23 @@ public class AssessmentPartThree {
// Lower case characters remain lower case, upper case remain upper case
// Lower case characters remain lower case, upper case remain upper case
// Any other characters are returned unchanged
// Any other characters are returned unchanged
return
'a'
;
return
returnChar
;
}
}
public
String
encryptedString
(
String
theMessage
,
int
theOffset
)
public
String
encryptedString
(
String
theMessage
,
int
theOffset
)
{
{
// 06 - encryptedMessage
String
alphabet
=
"abcdefghijklmnopqrstuvwxyz"
;
// Complete this method so that it uses encryptedCharacter to
String
codedString
=
""
;
// return the encrypted version of theMessage using theOffset
char
[]
theMessageChars
=
theMessage
.
toCharArray
();
int
x
=
-
1
;
for
(
int
i
=
0
;
i
<
theMessage
.
length
();
i
++)
{
char
character
=
theMessage
.
charAt
(
i
);
return
"Encryptred message"
;
codedString
+=
enryptedCharacter
(
character
,
theOffset
);
//codedString = String.valueOf(theMessageChars);
}
return
codedString
;
}
}
}
}
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