MCPcopy Create free account
hub / github.com/banq/jdonframework / isMasterCard

Method isMasterCard

src/main/java/com/jdon/util/UtilValidate.java:917–925  ·  view source on GitHub ↗

Checks to see if the cc number is a valid Master Card number @param cc a string representing a credit card number; Sample number: 5500 0000 0000 0004(16 digits) @return true, if the credit card number is a valid MasterCard number, false otherwise

(String cc)

Source from the content-addressed store, hash-verified

915 * @return true, if the credit card number is a valid MasterCard number, false otherwise
916 */
917 public static boolean isMasterCard(String cc) {
918 int firstdig = Integer.parseInt(cc.substring(0, 1));
919 int seconddig = Integer.parseInt(cc.substring(1, 2));
920
921 if ((cc.length() == 16) && (firstdig == 5) && ((seconddig >= 1) && (seconddig <= 5)))
922 return isCreditCard(cc);
923 return false;
924
925 }
926
927 /** Checks to see if the cc number is a valid American Express number
928 * @param cc - a string representing a credit card number; Sample number: 340000000000009(15 digits)

Callers 3

isAnyCardMethod · 0.95
getCardTypeMethod · 0.95
isCardMatchMethod · 0.95

Calls 1

isCreditCardMethod · 0.95

Tested by

no test coverage detected