import java.security.*; import java.io.*; import java.net.*; import java.util.*; public class ATM { private static int atmPort; private static String prompt = "ATM: "; private static Socket s = null; private static void authenticateUser(String user) { } private static boolean interpretCommand(String command) { Scanner sc = new Scanner(command); String c = sc.next(); if (c.equals("bye")) { return true; } else if (c.equals("begin-session")) { authenticateUser(sc.next()); } // Handle other commands ... return false; } public static void main(String[] args) { if (args.length != 1) { System.out.println("Usage: java ATM "); System.exit(0); } atmPort = Integer.parseInt(args[0]); try { s = new Socket("localhost", atmPort); } catch (Exception e) { e.printStackTrace(); System.exit(1); } System.out.print(prompt); BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in)); String userInput; try{ while( (userInput = stdIn.readLine()) != null ) { boolean stop = interpretCommand(userInput); if (stop) { break; } System.out.print(prompt); } } catch (IOException e) { e.printStackTrace(); } try { stdIn.close(); s.close(); } catch (IOException e) { e.printStackTrace(); } } }