Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. package bankAccount;
  2.  
  3. import javax.jws.WebMethod;
  4. import javax.jws.WebParam;
  5. import javax.jws.WebService;
  6.  
  7. @WebService
  8. public class Composition {
  9.     @WebMethod
  10.     public boolean transfer(@WebParam(name="from") String from,
  11.                             @WebParam(name="to") String to,
  12.                             @WebParam(name="amount") double amount) {
  13.  
  14.         // check account number
  15.         if (!BankAccountDB.getInstance().validateExistingBankAccount(from)
  16.             || !BankAccountDB.getInstance().validateExistingBankAccount(to)) {
  17.             return false;
  18.         }
  19.  
  20.         // check, if "from" user has enough money to send
  21.         if (BankAccountDB.getInstance().validateBalance(from, amount)) {
  22.             BankAccountDB.getInstance().subtractBalance(from, amount);
  23.             BankAccountDB.getInstance().addBalance(to, amount);
  24.             return true;
  25.         }
  26.  
  27.         return false;
  28.     }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement