YamoneyAccount implements Comparable<YamoneyAccount> { public static boolean isValidAccountNumber(String source) { if (source == null || source.isEmpty() || !isDigit(source)) { return false; } int n = fetchN(source); String x = fetchX(source, n); if (x == null) { return false; } String y = fetchY(source, n); if (y == null) { return false; } String z = fetchZ(source); return z != null && calculateRedundancy(x, y).equals(z); } YamoneyAccount(String account); String getAccount(); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); @Override int compareTo(YamoneyAccount o); static String calculateRedundancy(String x, String y); static boolean isValidAccountNumber(String source);  }
@Test public void testIncorrectAccounts() { assertFalse(YamoneyAccount.isValidAccountNumber("41003103403")); assertFalse(YamoneyAccount.isValidAccountNumber("410jhk3403")); assertFalse(YamoneyAccount.isValidAccountNumber("4106546535")); }