Efficiency

Just two small things that in case the number was very big could be helpful.
This commit is contained in:
Marcos
2019-04-11 12:20:53 +02:00
committed by GitHub
parent ffd4521601
commit f8605b957a

View File

@ -24,8 +24,8 @@ public class Caesar {
public static String encode(String message, int shift) {
String encoded = "";
while (shift >= 26) { // 26 = number of latin letters
shift -= 26;
if (shift >= 26) { // 26 = number of latin letters
shift %= 26;
}
final int length = message.length();
@ -62,8 +62,8 @@ public class Caesar {
public static String decode(String encryptedMessage, int shift) {
String decoded = "";
while (shift >= 26) { // 26 = number of latin letters
shift -= 26;
if (shift >= 26) { // 26 = number of latin letters
shift %= 26;
}
final int length = encryptedMessage.length();