Stringlowerbet="abcdefghijklmnopqrstuvwxyz";//creates a string containing all the letter of the alphabet in lowercase
upperChar=Character.isUpperCase(theChar);
theChar=Character.toLowerCase(theChar);
for(inti=0;i<alphabet.length;i++)
{
if(theChar==alphabet[i])
{
theOffset=theOffset+i;
break;
}
}
if(Character.isLetter(theChar))
{
if(theOffset<0)
{
theOffset=theOffset+26;
}
if(theOffset>alphabet.length)
{
theOffset=theOffset-26;
}
else
{
theChar=alphabet[theOffset];
}
}
else
{
returntheChar;
}
if(upperChar)
{
theChar=Character.toUpperCase(theChar);
}
returntheChar;
}
/* String lowerbet = "abcdefghijklmnopqrstuvwxyz"; //creates a string containing all the letter of the alphabet in lowercase
String capitalbet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // creates a string containing all the letters of the alphabet in uppercase
for (int i = 0; i < lowerbet.length(); i++) // creates a for loop that declares a variable called I, then iterates until i is greater than the length of the string lowerbet (in this case it would be 26)
...
...
@@ -44,9 +89,11 @@ public class AssessmentPartThree {
}
char newnumber = theChar; // assigns the value of theChar to newnum
returnnewnumber;// returns the value of newnum
return newnumber; // returns the value of newnum
}
*/
}
...
...
@@ -56,10 +103,23 @@ public class AssessmentPartThree {
// Complete this method so that it uses encryptedCharacter to
// return the encrypted version of theMessage using theOffset
StringBuilderstring=newStringBuilder();//creates an empty StringBuilder called String
Stringoutput="";
for(charletter:theMessage.toCharArray())
{
letter=enryptedCharacter(letter,theOffset);
output=output+letter;
}
returnoutput;
/* StringBuilder string = new StringBuilder(); //creates an empty StringBuilder called String
char j ; // creates an empty char called j
for (int i = 0; i < theMessage.length(); i++) // creates a for loop that iterates until i is greater then the length of whatever is stored in the string "theMessage"
...
...
@@ -93,11 +153,9 @@ public class AssessmentPartThree {
string.append (j); // returns string with the value of j added too it
}
returnstring.toString();// returns a string containing whatever is stored in the stringbuilder "string"
return string.toString(); // returns a string containing whatever is stored in the stringbuilder "string" */