CreditCardDisguise { public static String disguise(String cardNum) { int n = cardNum.length(); if (n < 12 || n > 20) { throw new IllegalArgumentException("Card Number length must be in (12,20}: " + cardNum); } return xxxs.substring(0, n - 4) + cardNum.substring(n - 4); }  static String disguise(String cardNum);  }
@Test public void testNormal() { assertEquals("XXXXXXXXXXXX1234", CreditCardDisguise.disguise("9876543210981234")); }
@Test public void testBoundary() { assertEquals("XXXXXXXXXXXXXXXX5678", CreditCardDisguise.disguise("11112222333344445678")); }
@Test(expected=IllegalArgumentException.class) public void testTooShort() { CreditCardDisguise.disguise("12345"); }
@Test(expected=IllegalArgumentException.class) public void testTooLong() { CreditCardDisguise.disguise("11112222333344445555+"); }