public void returnHolding(Holding holding) throws OverdrawnCreditException { // Remove holding from currentLoans ArrayList int holdingIndex = currentLoans.indexOf(holding); currentLoans.remove(holdingIndex); // Add holding to HistoryRecord history.addHistoryRecord( new HistoryRecord(holding, holding.getDefaultLoanFee() + holding.calculateLateFee())); // Deduct late fee from Members credit remainingCredit -= holding.calculateLateFee(); }
public void borrowHolding(Holding holding) throws InsufficientCreditException, MultipleBorrowingException { // Check if member has previously borrowed this holding if (history.getHistoryRecord(holding.getCode()) != null) { throw new MultipleBorrowingException(); } // Deduct loan fee if (remainingCredit - holding.getDefaultLoanFee() < 0) { throw new InsufficientCreditException(); } else remainingCredit -= holding.getDefaultLoanFee(); // Add holding to currentloans ArrayList currentLoans.add(holding); }