public class PasswordTestAuto {


        public static final String PASSWORD_FILE = "pwd.txt";
        
        public static final int NUM_USERS = 20;
        public static final String USER_PREFIX = "user";
        public static final String PASS_PREFIX = "pass";
        
        public static final int[] REMOVED_USERS = {0, 10, 37, 5, 19, 1, 10};
        public static final int[] EXISTING_USERS = {0, 4, 17, 5};
        
        public static void main(String[] args) {

                
                Passwords passwd = new Passwords(PASSWORD_FILE);
                

                System.out.println("\n\n Adding Users");
                //create some users
                for(int i = 0; i < NUM_USERS; i++ ) {
                        System.out.printf("User: %s Password: %s, Added: %B\n", 
                                        USER_PREFIX + i, (PASS_PREFIX + i), 
                                        passwd.addUser(USER_PREFIX + i, (PASS_PREFIX + i).toCharArray()));
                }
                                
                //try to add existing users
                for(int i = 0; i < EXISTING_USERS.length; i++) {
                System.out.printf("User: %s Password: %s, Added: %B\n", 
                                USER_PREFIX + EXISTING_USERS[i], (PASS_PREFIX + EXISTING_USERS[i]), 
                                passwd.addUser(USER_PREFIX + EXISTING_USERS[i], (PASS_PREFIX + EXISTING_USERS[i]).toCharArray()));
                }
                
                System.out.println("\n\n Removing Users");
                //remove some users
                for(int i = 0; i < REMOVED_USERS.length; i++) {
                        System.out.printf("User: %s Removed: %B\n", 
                                        USER_PREFIX + REMOVED_USERS[i],
                                        passwd.removeUser(USER_PREFIX + REMOVED_USERS[i]));
                }
                
                System.out.println("\n\n Checking if users exist");
                //check if some users exist
                for(int i = 0; i < NUM_USERS; i++ ) {
                        System.out.printf("User %2d: %B\n", i, passwd.isUser(USER_PREFIX + i));
                }
                
                //authenticate users

                System.out.println("\n\n Authenticating Users");
                for(int i = 0; i < NUM_USERS; i++ ) { 
                        //authenticate with correct and incorrect passwords.
                        System.out.printf("User: %7s Password: %7s, Authenticated: %5B Bad Password %5B\n", 
                                        USER_PREFIX + i, (PASS_PREFIX + i), 
                                        passwd.authenticateUser(USER_PREFIX + i, (PASS_PREFIX + i).toCharArray()),
                                        passwd.authenticateUser(USER_PREFIX + i, PASS_PREFIX.toCharArray())
                                        );
                }
        }

}