Advertisement
Guest User

Untitled

a guest
Jan 31st, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. import java.rmi.Naming;
  2. import java.rmi.registry.LocateRegistry;
  3. import java.rmi.registry.Registry;
  4.  
  5. public class ATM {
  6.  
  7. public static void main (String args[]) throws Exception {
  8. //get server address
  9. String serverAddress = args[0];
  10.  
  11. //get port
  12. int port = Integer.parseInt(args[1]);
  13.  
  14. // get operation
  15. String operation = args[2];
  16.  
  17. // Getting the registry
  18. Registry registry = LocateRegistry.getRegistry(port);
  19.  
  20. // Looking up the registry for the remote object
  21. BankImpl bank = (BankImpl) registry.lookup("//" + serverAddress +"/Bank");
  22.  
  23. try {
  24. if(operation.equals("login")) {
  25. String username = args[3];
  26. String password = args[4];
  27.  
  28.  
  29. String sessionID = bank.login(username,password);
  30.  
  31. bank.setSessionID(sessionID);
  32. }
  33. if(operation.equals("withdraw")) {
  34. int account = Integer.parseInt(args[3]);
  35. int amount = Integer.parseInt(args[4]);
  36.  
  37. bank.withdraw(account,amount,bank.getSessionID());
  38. }
  39. if(operation.equals("deposit")) {
  40. int account = Integer.parseInt(args[3]);
  41. int amount = Integer.parseInt(args[4]);
  42.  
  43. bank.deposit(account,amount,bank.getSessionID());
  44. }
  45. if(operation.equals("inquiry")) {}
  46. if(operation.equals("statement")) {}
  47.  
  48.  
  49. }
  50. catch (Exception e) {}
  51. }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement