Main { (@ static public void main(String args[]) throws Exception { Account a = new Account(); Username u = new Username(); Password p = new Password(); Password pv = new Password(); BufferedReader inputLine; String input = new String(); boolean operational = true; boolean flag = true; // print welcome message BrokerSim b = BrokerSim.parse(new FileInputStream("../../Broker.input")); a = null; while(operational) { while (a == null) { System.out.println("\n\n------------------------------"); System.out.println("Log On to the Brokerage System"); System.out.println("------------------------------\n"); System.out.print("Username : "); inputLine = new BufferedReader (new InputStreamReader(System.in)); input = inputLine.readLine(); u = new Username(input); if (input.equals("quit")) { System.out.println("see ya"); // print exit message; operational = false; break; } a = b.check_Username(u); if (a != null) { System.out.print("Password : "); inputLine = new BufferedReader (new InputStreamReader(System.in)); input = inputLine.readLine(); if (input.equals(a.get_password().get_pword())) { System.out.println("Good"); b.loggedOn(a); } else { System.out.println("\nInvalid Password"); a = null; } } else { System.out.println("Invalid Username"); // create new Account // Remember to addElement to the List(Account)... } } } } @) } BrokerSim { traversal checkAccount (CheckUsernameVisitor cv) { through AccountList to Username; } Account check_Username(Username username) (@ Account a = new Account(); CheckUsernameVisitor cv = new CheckUsernameVisitor(); cv.set_username(username); this.checkAccount(cv); a = cv.get_return_val(); return a; @) } BrokerSim { void loggedOn(Account a) (@ Operation current_operation = new Invalid(); OpCode quit_opcode = new OpCode("Quit"); System.out.println("Time to start making some $$$ :-) "); while (current_operation.get_opCode() != quit_opcode) { show_Operations(); break; } @) } BrokerSim { traversal allOperations (DisplayOpVisitor dv) { to {Buy, Sell, MarketReport, AccountReport, Quit}; } void show_Operations() (@ DisplayOpVisitor dv = new DisplayOpVisitor(); this.allOperations(dv); @) } CheckUsernameVisitor { init (@ account = null; @) before Account (@ caccount = host; @) before Username (@ if (host.get_uname().equals(username.get_uname())) { account = caccount; } @) return Account (@ account @) } DisplayOpVisitor { before BrokerSim (@ System.out.println("---------------------------"); System.out.println("Please choose an operation:"); System.out.println("---------------------------\n"); @) before Operation (@ System.out.println(host.get_opCode().get_o() + "\t" + host.get_opDesc().get_desc()); @) } BrokerSim { traversal all(DisplayVisitor) {to *;} (@ void displayAll() { DisplayVisitor dv = new DisplayVisitor(); this.all(dv); return; } @) }