Skip to content
Snippets Groups Projects
DepositServiceImpl.java 698 B
Newer Older
unknown's avatar
unknown committed
package ufrn.imd.service.impl;

unknown's avatar
unknown committed
import lombok.extern.java.Log;
unknown's avatar
unknown committed
import ufrn.imd.domain.Account;
import ufrn.imd.service.DepositService;

import java.rmi.RemoteException;
import java.util.Optional;

unknown's avatar
unknown committed
@Log
unknown's avatar
unknown committed
public class DepositServiceImpl implements DepositService {

    public DepositServiceImpl() {
        super();
    }

    public void deposit(Double value, Optional<Account> acOp) throws RemoteException, RuntimeException {
        Account account = acOp.orElseThrow(() -> new RuntimeException("Null User!"));
        if(account.getBalance() < value) throw new RuntimeException("There's no money!");
        account.setBalance(account.getBalance() - value);
unknown's avatar
unknown committed
        log.info("deposit");
unknown's avatar
unknown committed
    }

}