@Test public void testPayCompleteFine() { float fines = 5f; float payment = 5f; member.addFine(fines); System.out.println( "\nThus test demonstrates a complete payment of a fine. The test is successful if the fine value after payment is at 0."); boolean b; member.payFine(payment); System.out.print( "Fines value: " + fines + ", Payment value: " + payment + ", Fines value after payment: " + member.getFineAmount()); if (member.getFineAmount() == 0f) { b = true; System.out.println(" -- PASS"); } else { b = false; System.out.println(" -- FAIL"); } assertTrue(b); }
@Test public void testPayNegativeFine() { float fines = 5f; float payment = -5f; member.addFine(fines); System.out.println( "\nThus test demonstrates a negative payment of a fine. The test is successful if the function " + "\ngives out an exception and does not change the fine value."); boolean b; member.payFine(payment); System.out.print( "Fines value: " + fines + ", Payment value: " + payment + ", Fines value after payment: " + member.getFineAmount()); if (member.getFineAmount() == fines) { b = true; System.out.println(" -- PASS"); } else { b = false; System.out.println(" -- FAIL"); } assertTrue(b); }
@Test public void testPaySmallFine() { float fines = 5f; float payment = 2f; member.addFine(fines); System.out.println( "\nThus test demonstrates a partial payment of a fine. The test is successful if the fine value after payment is lower than its " + "\nprevious value."); boolean b; member.payFine(payment); System.out.print( "Fines value: " + fines + ", Payment value: " + payment + ", Fines value after payment: " + member.getFineAmount()); if (member.getFineAmount() < fines) { b = true; System.out.println(" -- PASS"); } else { b = false; System.out.println(" -- FAIL"); } assertTrue(b); }