Newer
Older
package ufrn.imd.service.impl;
import ufrn.imd.domain.Account;
import ufrn.imd.log.Log;
import ufrn.imd.service.DepositService;
import java.rmi.RemoteException;
import java.util.Optional;
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);
Log.info(DepositServiceImpl.class, "deposit");
}
}