//--> Note: Comments starting with //--> are meta-comments about how to write //--> OO Java code and wouldn't appear in a production environment. //--> The special comments /** ... */ enclose javadoc text, used to //--> document the contractual interface of each class. /** * Class representing a login security system. Manages * UI for end users and system operations staff. Responsible * for username/password validity checks. * @author John Panzer * @version 0.1 */ public class SecuritySystem { private final LogMonitor _logMonitor; // UI for log messages private final PasswordPopup _passwordPopup; // UI for user logins /** Constructor */ public SecuritySystem() { _logMonitor = new LogMonitor(); _passwordPopup = new PasswordPopup(this); } /** Shows UI components on the screen. */ public void show() { //--> Note use of pure delegation here _logMonitor.show(); _passwordPopup.show(); } /** * Attempt to perform a login on behalf of the given user. * Requires non-null username and password. * Returns true if user has been successfully authenticated, * false otherwise. * Called from PasswordPopup. */ public boolean doLogin(String username, char[] password) { //assert (username!=null); //assert (password!=null); //--> For now, just pretend we fail every time: _logMonitor.log("Login for user name "+username+" failed."); return false; } public static void main(String[] args) { //--> In this case we want to create a SecuritySystem //--> object and start it running. It manages itself //--> from that point forward. new SecuritySystem().show(); //--> We can fall off the end of main() here because //--> this is an AWT application... we keep running //--> until System.exit() is called. } }