Exemple #1
0
 public String performBill() {
   sender.setCheckingaccount(sender.getCheckingaccount() - amount);
   recipient.setCheckingaccount(recipient.getCheckingaccount() + amount);
   em.merge(sender);
   em.merge(recipient);
   return sender.getCheckingaccount().toString();
 }
Exemple #2
0
 @Override
 public boolean setAmount(Long amount, String username) {
   sender =
       (UserEntity)
           em.createNamedQuery("UserEntity.findByUsername")
               .setParameter("username", username)
               .getSingleResult();
   if (amount > sender.getCheckingaccount()) {
     System.out.println("You don't have enough money");
     return false;
   } else {
     this.amount = amount;
     return true;
   }
 }
Exemple #3
0
 public void checkBillDetails() throws IncorrectBillDetailsException {
   Long sendAmount = sender.getCheckingaccount();
   if ((sendAmount - amount) < 0)
     throw new IncorrectBillDetailsException(
         "Error: Bill details not correct. Check the amount of the transaction");
 }