-
Notifications
You must be signed in to change notification settings - Fork 19.9k
Update Caesar.java #412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Caesar.java #412
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Work! I have some requests.
ciphers/Caesar.java
Outdated
char current = message.charAt(i); // Java law : char + int = char | ||
|
||
if (current >= 'A' && current <= 'Z') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this complex if
use Character.isLetter(c)
see here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Character.isLetter(c) method return true if the input was 'ф' or 'أ' or '褥' while we don't shift them in this method , it's just for shifting Latin letters .
ciphers/Caesar.java
Outdated
for (int i = 0; i < length; i++) { | ||
char current = encryptedMessage.charAt(i); | ||
if (current >= 'A' && current <= 'Z') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing as above.
ciphers/Caesar.java
Outdated
System.out.println("(E)ncode or (D)ecode ?"); | ||
char choice = input.next().charAt(0); | ||
if (choice == 'E' || choice == 'e') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you can simpler use a switch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for advice here 👍
changes :-
*fix documentation
*methods (encode,decode) can take any number of shifts now and better performed.