tracks/java/exercises/rotational-cipher/src/example/java/RotationalCipher.java in trackler-2.2.0.3 vs tracks/java/exercises/rotational-cipher/src/example/java/RotationalCipher.java in trackler-2.2.0.4
- old
+ new
@@ -1,15 +1,14 @@
+class RotationalCipher {
-public class RotationalCipher {
+ private int shiftKey;
- int shiftKey;
-
RotationalCipher(int shiftKey) {
this.shiftKey = shiftKey;
}
- public String rotate(String data) {
+ String rotate(String data) {
StringBuilder dataStringBuilder = new StringBuilder();
for (char c : data.toCharArray()) {
if (Character.isUpperCase(c)) {
dataStringBuilder.append(getReplacementCharacter(c, 'A', 'Z'));
} else if (Character.isLowerCase(c)) {
@@ -23,15 +22,13 @@
/**
* For Uppercase CaseStart = 'A' and CaseEnd = 'Z'
* For Lowercase CaseStart = 'a' and CaseEnd = 'z'
*/
- private char getReplacementCharacter(char characterToReplace,
- char alphabetCaseStart, char alphabetCaseEnd) {
+ private char getReplacementCharacter(char characterToReplace, char alphabetCaseStart, char alphabetCaseEnd) {
char replacementCharacter = (char) (characterToReplace + shiftKey);
if (replacementCharacter > alphabetCaseEnd) {
- replacementCharacter = (char) ((alphabetCaseStart - 1) +
- (replacementCharacter % alphabetCaseEnd));
+ replacementCharacter = (char) ((alphabetCaseStart - 1) + (replacementCharacter % alphabetCaseEnd));
}
return replacementCharacter;
}
}