Commit 77b88575 authored by Neil's avatar Neil

21:31 03/12/18

parent 39bb1959
......@@ -8,7 +8,29 @@ public class AssessmentPartThree {
// - so a becomes b, b becomes c, etc
// If a value of -2 is chosen a becomes y, b becomes z and so on
public char enryptedCharacter(char theChar, int theOffset)
public static void main(String[] args)
{
String input = "z";
int offset = 3;
System.out.print(input + " ");
System.out.println(encryptedString(input, offset));
System.out.println(-3 % 26);
char a3 = (char) ((char) 'z' - 2);
System.out.println(a3);
}
/*
"hello,5,mjqqt",
"Java Coding,-3,Gxsx Zlafkd",
"dandelion,8,livlmtqwv",
"ktixevzout,-6,encryption"
*/
public static char enryptedCharacter(char theChar, int theOffset) //REMEMBER TO REMOVE STATIC
{
// 05 - encryptedCharacter
// Complete this method so that it returns the encrypted character for
......@@ -35,11 +57,15 @@ public class AssessmentPartThree {
( + 97) + ASCII a/A to return result to ASCII char
(char) result needs to be casted to char
*/
//COPY THIS OVER FROM LAB COMPUTER TO PRESERVE FORMATTING
return theChar;
}
//THE PROBLEM IS WITH MINUS NUMBERS!!!! NEED TO HAVE A WAY TO DEAL WITH IT ROLLING BACKWARDS!!!
public String encryptedString(String theMessage, int theOffset)
public static String encryptedString(String theMessage, int theOffset) //REMEMBER TO REMOVE STATIC
{
// 06 - encryptedMessage
// Complete this method so that it uses encryptedCharacter to
......@@ -52,7 +78,7 @@ public class AssessmentPartThree {
for(int i = 0; i < chaMessageArr.length; i++)
//loop to run through each character in encrypted message
{
chaResultArr[i] = enryptedCharacter(chaMessageArr[i], theOffset);
chaResultArr[i] = enryptedCharacter(chaMessageArr[i], (theOffset));
//passing each character to decryption method and saving result in array
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment