// The simplest form of encryption is the rotation cipher (also known as Caeser's Cipher)
// The simplest form of encryption is the rotation cipher (also known as Caeser's Cipher)
...
@@ -17,16 +16,64 @@ public class AssessmentPartThree {
...
@@ -17,16 +16,64 @@ 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';
char[]alphabet={'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'};// creates an array which has each letter of the alphabet
intletterPlace=0;//creates an int and the value is 0
theChar=Character.toLowerCase(theChar);//makes theChar equal to the lowercase value of theChar
booleanupperCase=Character.isUpperCase(theChar);// makes it equal to the uppercase value of theChar
if(Character.isLetter(theChar))
{
if(theOffset<0)
{
theOffset=theOffset+26;
}
if(theOffset>alphabet.length)// if the value of theOfset is greater than the length of the string alphabet
{
theOffset=theOffset-26;
}
else
{
theChar=alphabet[theOffset];
}
}
else
{
returntheChar;
}
for(inti=0;i<alphabet.length;i++)// creates a 'for' loop that runs as long as 'i' is less than the length of the array string alphabet
{
if(theChar==alphabet[i])
{
theOffset=theOffset+i;
}
}
if(upperCase)
{
theChar=Character.toUpperCase(theChar);//makes thechar equal to the uppercase value of thechar
// Complete this method so that it uses encryptedCharacter to
// Complete this method so that it uses encryptedCharacter to
// return the encrypted version of theMessage using theOffset
// return the encrypted version of theMessage using theOffset
return"Encryptred message";
Stringoutput="";
for(charletter:theMessage.toCharArray())//creates a 'for' loop that iterates the char "letter" through theMessage.tochararray
{
output=output+letter;
letter=enryptedCharacter(letter,theOffset);// makes letter equal to the amount which has been obtained while running theMessgae through the encrypted character method above