brainfrz icon

LoginInfo Skeleton

brainfrz | PRO | 01/29/16 06:26:52 PM UTC | 0 ⭐ | 865 👁️ | Never ⏰ | []
Java |

9.41 KB

|

None

|

0 👍

/

0 👎

/******************************************************************************
 * Program Name   : Week 2 - Login Info
 * Author         : Terry Weiss
 * Date           : January 29, 2016
 * Course/Section : CSC264 - 001
 * Program Description: This program will create usernames and passwords for
 *     students at OCC using their first and last name. The username will be
 *     the student's first two letters of their first name, followed by the
 *     first three letters of their last name, followed by a random digit
 *     1 and 3. If either name is too short their full first/last name is used.
 *     All usernames are in all lowercase letters. The password will default to
 *     the user's first name (in all lower case letters). The usernames and
 *     passwords each in their own array. The user may create up to 10
 *     username/password combinations. Duplicate usernames are prevented by
 *     adding another digit (1, 2, or 3) onto the end of the duplicate username,
 *     thus creating a unique username. When the user stops creating usernames,
 *     all of the usernames and passwords are displayed on the screen.
 *
 * Methods:
 * -------
 * promptName    - Prompts for a first and last name or quit value
 * randomNumber  - Generates a random number within range (1 through 3 inclusive)
 * generateID    - Generates the ID using first and last name
 * generatePwd   - Generates the passwords using their first name in lower case
 * uniqueID      - Goes through ID list confirming each ID is unique or replacing
 * displayLogins - Displays a list of all the IDs and passwords
 * Main          - Reads the names, creates the login info and displays them
 ******************************************************************************/
 
import java.util.Random;
 
class LoginInfoTTWSkeleton
{
 
    /**************************************************************************
     * Method Name    : LoginInfo - Main
     * Author         : Terry Weiss
     * Date           : January 29, 2016
     * Course/Section : CSC264 - 001
     * Program Description: This method will read a name entered by the user. It
     *     then creates a new String with the name centered for console output,
     *     and displays it.
     *
     * BEGIN main
     *    Init location to 0
     *    Clear screen
     *    Display input title
     *    Prompt name {prompt name method, returning name array}
     *    WHILE (name is array of two elements)
     *        Generate and assign ID to element in ID list {generate ID method}
     *        Generate and assign password to element in Pwd list {generate pwd method}
     *        Increment location
     *        IF (array is full)
     *            Set name to array of one element
     *        ELSE
     *            Prompt name {prompt name method}
     *        END IF
     *    END WHILE
     *    Check all IDs are unique {uniqueID method}
     *    Clear screen
     *    Display output title
     *    Display all login info {display logins method}
     * END Read Name
     **************************************************************************/
    public static void main(String[] args)
    {
        //TODO Reads the names, creates the login info and displays them
 
    }//end method main
 
 
    //Input methods
 
    /**************************************************************************
     * Method Name    : LoginInfo - Prompt Name
     * Author         : Terry Weiss
     * Date           : January 29, 2016
     * Course/Section : CSC264 - 001
     * Program Description: This method will prompt for the student's first
     *     name. If it's not the quit string, it'll prompt for the last name and
     *     return an array of the full name. Otherwise, it'll return a
     *     one-element array with quit string.
     *
     * BEGIN Prompt Name
     *    Prompt first name
     *    IF (first name isn't quit strig) THEN
     *        Instantiate two-element array
     *        Assign first name to element 0
     *        Prompt last name to element 1
     *        Return array of first and last names
     *    ELSE
     *        Return one-element array with quit string
     *    END IF
     * END Prompt Names
     **************************************************************************/
    private static String[] promptName(String quitString)
    {
        //TODO Prompts the full first and last name
 
    }//end method Prompt Name
 
 
    //Calculation methods
 
    /**************************************************************************
     * Method Name    : LoginInfo - Random Number
     * Author         : Terry Weiss
     * Date           : January 29, 2016
     * Course/Section : CSC264 - 001
     * Program Description: This method will generate a random number between
     *     given min and max.
     *
     * BEGIN Random Number
     *    Init number to 0
     *    IF (min >= max) THEN
     *        Set number to min
     *    ELSE
     *        Generate a random number between min and max and set it to number
     *    END IF
     *    Return number
     * END Random number
     **************************************************************************/
    private static int randomNumber(int min, int max, Random generator)
    {
        //TODO Generates a random number within range (1 through 3 inclusive)
 
    }//end method Random Number
 
 
    /**************************************************************************
     * Method Name    : LoginInfo - Generate ID
     * Author         : Terry Weiss
     * Date           : January 29, 2016
     * Course/Section : CSC264 - 001
     * Program Description: This method will generate an ID using the student's
     *     first name, last name and a generated number.
     *
     * BEGIN Generate ID
     *    Init ID to an empty string
     *    Append to ID first two letters of first name
     *    Append to ID first three letters of last name
     *    Generate and append a random digit between min and max
     *    Return ID
     * END Generate ID
     **************************************************************************/
    private static String generateID(String firstName, String lastName,
                                        int min, int max, Random generator)
    {
        //TODO Generates the ID using first and last name
 
    }//end method Generate ID
 
    /**************************************************************************
     * Method Name    : LoginInfo - Generate Pwd
     * Author         : Terry Weiss
     * Date           : January 29, 2016
     * Course/Section : CSC264 - 001
     * Program Description: This method generates a password by converting the
     *     student's first name to lower case.
     *
     * BEGIN Generate Pwd
     *    Return first name in lower case
     * END Generate Pwd
     **************************************************************************/
    private static String generatePwd(String firstName)
    {
        //TODO Generates the passwords using their first name in lower case
 
    }//end method Generate Pwd
 
 
    //Data Management methods
 
    /**************************************************************************
     * Method Name    : LoginInfo - Unique ID
     * Author         : Terry Weiss
     * Date           : January 29, 2016
     * Course/Section : CSC264 - 001
     * Program Description: This method checks through each element of the ID
     *     list, comparing the current ID with the remaining IDs. If there is
     *     a duplicate, the compared ID gets changed by appending another
     *     random digit.
     *
     * BEGIN Unique ID
     *    FOR (each element left in ID list)
     *        FOR (each element left in ID list)
     *            IF (ID matches element) THEN
     *                Append a random number in range to ID at current element
     *            END IF
     *        END FOR
     *    END FOR
     * END Unique ID
     **************************************************************************/
    private static void uniqueID(String[] IDList, int min, int max)
    {
        for (int ID = 0; ID < IDList.length - 1; ID++)
        {
            for (int comparedID = ID + 1; comparedID < IDList.length; comparedID++)
            {
                if (IDList[ID].equals(IDList[comparedID]))
                {
                    IDList[comparedID] = IDList[comparedID].append(randomNumber(min, max));
                }
            }
        }
 
    }//end class Unique ID
 
 
    //Output methods
 
    /**************************************************************************
     * Method Name    : LoginInfo - Display Logins
     * Author         : Terry Weiss
     * Date           : January 29, 2016
     * Course/Section : CSC264 - 001
     * Program Description: This method displays each user ID and password
     *
     * BEGIN Display Logins
     *    Init ID to 0
     *    WHILE (ID in list isn't quit value and ID is less than max length)
     *        Display ID
     *        Display password at ID
     *        Increment ID
     *    END WHILE
     * END Display Logins
     **************************************************************************/
    private static void displayLogins(String[] IDList, String[] pwdList)
    {
        //TODO Displays a list of all the IDs and passwords
 
    }//end method Display Logins
}//end class LoginInfoTTW

Comments