Description
- a method stringInBounds which takes a string plainText and returns a Boolean value
- Initialize a Boolean ok to true
- Start a for loop (int i=0; i<plainText.length(); i++)
- if (plainText.charAt(i) < LOWER_BOUND || plainText.charAt(i) > UPPER_BOUND), return false
- close for loop
- return true
- Create a method encryptCaesar which takes a string plainText and an int key and returns a string value
- Initialize a string encryptedText to “”
- if(stringInBounds(plainText)), Start a for loop for (int i=0; i<plainText.length(); i++)
- initialize a char thisChar to plainText.charAt(i)
- initialize an int encryptedCharInt to ((int)thisChar+key)
- while (encryptedCharInt>UPPER_BOUND), subtract encryptedCharInt by RANGE
- increase encryptedText by (char)encryptedCharInt
- close for loop
- return encryptedText
- Create a method encryptBellaso which takes two strings plainText and bellasoStr and returns a string value
- Initialize a string encryptedText to “”
- Initialize int bellasoStrLength to bellasoStr.length()
- if(stringInBounds(plainText)), Start a for loop for (int i=0; i<plainText.length(); i++)
- initialize a char thisChar to plainText.charAt(i)
- initialize an int encryptedCharInt to ((int)thisChar+(int)bellasoStr.charAt(i %bellasoStrLength))
- while (encryptedCharInt>UPPER_BOUND), subtract encryptedCharInt by RANGE
- increase encryptedText by (char)encryptedCharInt
- close for loop
- return encryptedText
- Create a method decryptCaesar which takes a string encryptedText and an int key and returns a string value
- Initialize a string decryptedText to “”
- Start a for loop for (int i=0; i< encryptedText.length(); i++)
- initialize a char thisChar to encryptedText.charAt(i)
- initialize an int decryptedCharInt to ((int)thisChar-key)
- while (decryptedCharInt<LOWER_BOUND), increase decryptedCharInt by RANGE
- increase decryptedText by (char) decryptedCharInt
- close for loop
- return dencryptedText
- Create a method dencryptBellaso which takes two strings encryptedText and bellasoStr and returns a string value
- Initialize a string dencryptedText to “”
- Initialize int bellasoStrLength to bellasoStr.length()
- Start a for loop for (int i=0; i<encryptedText.length(); i++)
- initialize a char thisChar to encryptedText.charAt(i)
- initialize an int dencryptedCharInt to ((int)thisChar-(int)bellasoStr.charAt(i %bellasoStrLength))
- while (dencryptedCharInt<LOWER_BOUND), increase dencryptedCharInt by RANGE
- increase dencryptedText by (char)dencryptedCharInt
- close for loop
- return dencryptedText