Tarkvara kvaliteet ja standardid projekt
Programmi kood:
public class EX03 {
/**
* Given text and a rotation, encrypts text.
* @param plainText plain text, readable by humanoids
* with relative ease.
* @param rotation
* @return encrypted text
*/
public static String encrypt(String plainText, int rotation) {
if (plainText == null)
return null;
if (plainText.isEmpty())
return plainText;
String encrypted = "";
//plainText = minimizeText(plainText);
plainText = plainText.toLowerCase();
if (rotation % 26 == 0)
return plainText;
if (rotation < 0)
return null;
int len = plainText.length();
for (int x = 0; x < len; x++) {
char c = plainText.charAt(x);
if (Character.isLetter(c))
if (c + rotation >= 97)
c = (char) (97 + (c + rotation - 97) % 26);
else