Last active
July 13, 2016 17:16
-
-
Save c0rp-aubakirov/28e83bdbdf0f448aff042728d6cd43c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boolean consecutiveAscending = true; | |
boolean consecutiveDescending = true; | |
// Check to see if the newPin is made up of consecutive numbers in | |
// ascending order | |
for (int j = 0; j < newPin.length() - 1; j++) { | |
if (Convert.toLong(newPin.substring(j, j + 1)) == null | |
|| Convert.toLong(newPin.substring(j + 1, j + 2)) == null) { | |
consecutiveAscending = false; | |
break; | |
} | |
int current = Integer.parseInt(newPin.substring(j, j + 1)); | |
int next = Integer.parseInt(newPin.substring(j + 1, j + 2)); | |
if ((current + 1) != next) { | |
consecutiveAscending = false; | |
break; | |
} | |
} | |
if (consecutiveAscending) { | |
throw new SmartPinConsecutiveException(); | |
} | |
// Check to see if the newPin is made up of consecutive numbers in | |
// descending order | |
for (int j = 0; j < newPin.length() - 1; j++) { | |
if (Convert.toLong(newPin.substring(j, j + 1)) == null | |
|| Convert.toLong(newPin.substring(j + 1, j + 2)) == null) { | |
consecutiveDescending = false; | |
break; | |
} | |
int current = Integer.parseInt(newPin.substring(j, j + 1)); | |
int next = Integer.parseInt(newPin.substring(j + 1, j + 2)); | |
if ((current - 1) != next) { | |
consecutiveDescending = false; | |
break; | |
} | |
} | |
if (consecutiveDescending) { | |
throw new SmartPinConsecutiveException(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment