@Override public void addFine(float fine) { if (fine < 0) { throw new RuntimeException(String.format("Member: addFine : fine cannot be negative")); } totalFines += fine; updateState(); }
@Override public void payFine(float payment) { if (payment < 0 || payment > totalFines) { throw new RuntimeException( String.format("Member: addFine : payment cannot be negative or greater than totalFines")); } totalFines -= payment; updateState(); }
public void refundLoan(ILoan loan) { if (fine == null) { } else { throw new RuntimeException( String.format("Member: refundLoan : illegal operation in state: %s", state)); } totalFines -= 0; updateState(); }
@Override public void removeLoan(ILoan loan) { if (loan == null || !loanList.contains(loan)) { throw new RuntimeException( String.format("Member: removeLoan : loan is null or not found in loanList")); } loanList.remove(loan); updateState(); }
@Override public void addLoan(ILoan loan) { if (!borrowingAllowed()) { throw new RuntimeException( String.format("Member: addLoan : illegal operation in state: %s", state)); } loanList.add(loan); updateState(); }