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 { // list traversals... loggedOn(Account a) (@ @) } 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; @) } checkUsernameVisitor { init (@ account = null; @) before Account (@ caccount = host; @) before Username (@ if (host.get_uname().equals(username.get_uname())) { account = caccount; } @) return Account (@ account @) } BrokerSim { traversal all(DisplayVisitor) {to *;} // traversal checkAccount(CheckVisitor) (@ void displayAll() { DisplayVisitor dv = new DisplayVisitor(); this.all(dv); return; } @) }