Code example for BigDecimal

Methods: compareTo

0
 
    @Override 
	public Transaction withdraw(BigDecimal amount) throws InvalidInputException, InsufficientFundsException {
		BigDecimal overdraftLimit = Bank.getInstance().getPaymentSchedule()
				.getOverdraftLimit(); 
		if (amount.compareTo(this.getBalance().add(overdraftLimit)) < 0) {
			return super.withdraw(amount);
		} else { 
			applyFee(Bank.getInstance().getPaymentSchedule().getOverdraftFee()); 
			throw new InsufficientFundsException(getBalance().add(overdraftLimit), amount);
		} 
	} 
 
	@Override 
	public BigDecimal getInterestRate() {
		return BigDecimal.ZERO;
	} 
 
	@Override 
	protected BigDecimal getMonthlyCharge() {
		return Bank.getInstance().getPaymentSchedule().getCheckingCharge();