### Question:
CreditCardGenerator { public CreditCardGenerator(){ this.type = null; } CreditCardGenerator();  CreditCardGenerator(String type); String generate(); String getType(); void setType(String type);  }### Answer:
@Test public void testCreditCardGenerator(){ for (int i=0;i<100;i++) { CreditCardGenerator creditCardGenerator = new CreditCardGenerator(); String value = creditCardGenerator.generate(); switch (creditCardGenerator.getType()){ case "AMEX": Assert.assertEquals(value.charAt(0),'3'); Assert.assertEquals(value.length(),15); break; case "VISA": Assert.assertEquals(value.charAt(0),'4'); Assert.assertEquals(value.length(),16); break; case "MASTERCARD": Assert.assertEquals(value.charAt(0),'5'); Assert.assertEquals(value.length(),16); break; case "DISCOVER": Assert.assertEquals(value.charAt(0),'6'); Assert.assertEquals(value.length(),16); break; case "JCB": Assert.assertEquals(value.charAt(0),'3'); Assert.assertEquals(value.charAt(1),'5'); Assert.assertEquals(value.length(),16); break; default: Assert.fail("Not a valid type"); } } }