Skip to content

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

Merged
merged 3 commits into from
Apr 12, 2018
Merged

Update Caesar.java #412

merged 3 commits into from
Apr 12, 2018

Conversation

cyberkhalil
Copy link
Contributor

@cyberkhalil cyberkhalil commented Apr 9, 2018

changes :-
*fix documentation
*methods (encode,decode) can take any number of shifts now and better performed.

Copy link

@christianbender christianbender left a 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.

char current = message.charAt(i); // Java law : char + int = char

if (current >= 'A' && current <= 'Z') {

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

Copy link
Contributor Author

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 .

for (int i = 0; i < length; i++) {
char current = encryptedMessage.charAt(i);
if (current >= 'A' && current <= 'Z') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing as above.

System.out.println("(E)ncode or (D)ecode ?");
char choice = input.next().charAt(0);
if (choice == 'E' || choice == 'e') {

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for advice here 👍

@christianbender christianbender merged commit 2d5a9b1 into TheAlgorithms:master Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants