Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.rmi.Naming;
- import java.rmi.registry.LocateRegistry;
- import java.rmi.registry.Registry;
- public class ATM {
- public static void main (String args[]) throws Exception {
- //get server address
- String serverAddress = args[0];
- //get port
- int port = Integer.parseInt(args[1]);
- // get operation
- String operation = args[2];
- // Getting the registry
- Registry registry = LocateRegistry.getRegistry(port);
- // Looking up the registry for the remote object
- BankImpl bank = (BankImpl) registry.lookup("//" + serverAddress +"/Bank");
- try {
- if(operation.equals("login")) {
- String username = args[3];
- String password = args[4];
- String sessionID = bank.login(username,password);
- bank.setSessionID(sessionID);
- }
- if(operation.equals("withdraw")) {
- int account = Integer.parseInt(args[3]);
- int amount = Integer.parseInt(args[4]);
- bank.withdraw(account,amount,bank.getSessionID());
- }
- if(operation.equals("deposit")) {
- int account = Integer.parseInt(args[3]);
- int amount = Integer.parseInt(args[4]);
- bank.deposit(account,amount,bank.getSessionID());
- }
- if(operation.equals("inquiry")) {}
- if(operation.equals("statement")) {}
- }
- catch (Exception e) {}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement