Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Part03
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
Assessment
Part03
Commits
2fff3ac5
Commit
2fff3ac5
authored
Dec 10, 2018
by
neil.whitehead
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
12:19 10/12/18
parent
39bb1959
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
25 deletions
+35
-25
AssessmentPartThree.java
src/AssessmentPartThree.java
+31
-24
AssessmentPartThreeTest.java
src/AssessmentPartThreeTest.java
+4
-1
No files found.
src/AssessmentPartThree.java
View file @
2fff3ac5
public
class
AssessmentPartThree
{
public
class
AssessmentPartThree
{
// The simplest form of encryption is the rotation cipher (also known as Caeser's Cipher)
// An offset value is chosen to encrypt a message. Each letter is replaced by the
...
...
@@ -17,6 +18,10 @@ public class AssessmentPartThree {
// Lower case characters remain lower case, upper case remain upper case
// Any other characters are returned unchanged
//Dealing with negative offsets
theOffset
=
(
theOffset
<
0
)
?
26
+
theOffset
:
theOffset
;
//ensures that the offset will "wrap around"
//Uppercase characters
if
((
theChar
>=
65
)
&&
(
theChar
<=
90
))
//65 to 90 = A to B
{
...
...
@@ -35,7 +40,9 @@ public class AssessmentPartThree {
( + 97) + ASCII a/A to return result to ASCII char
(char) result needs to be casted to char
*/
return
theChar
;
//any non alphabetical chars will fall through and return original char
}
...
...
src/AssessmentPartThreeTest.java
View file @
2fff3ac5
...
...
@@ -23,7 +23,10 @@ class AssessmentPartThreeTest {
"q,-3,n"
,
"G,6,M"
,
"5,-3,5"
,
"T,-7,M"
"T,-7,M"
,
"a,31,f"
,
"T,-33,M"
,
"!, 2, !"
})
void
testEnryptedCharacter
(
char
theChar
,
int
theOffset
,
char
encChar
)
{
assertEquals
(
encChar
,
test
.
enryptedCharacter
(
theChar
,
theOffset
));
...
...
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