brainfrz

LoginInfo Skeleton

Jan 29th, 2016
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.41 KB | None | 0 0
  1. /******************************************************************************
  2.  * Program Name   : Week 2 - Login Info
  3.  * Author         : Terry Weiss
  4.  * Date           : January 29, 2016
  5.  * Course/Section : CSC264 - 001
  6.  * Program Description: This program will create usernames and passwords for
  7.  *     students at OCC using their first and last name. The username will be
  8.  *     the student's first two letters of their first name, followed by the
  9.  *     first three letters of their last name, followed by a random digit
  10.  *     1 and 3. If either name is too short their full first/last name is used.
  11.  *     All usernames are in all lowercase letters. The password will default to
  12.  *     the user's first name (in all lower case letters). The usernames and
  13.  *     passwords each in their own array. The user may create up to 10
  14.  *     username/password combinations. Duplicate usernames are prevented by
  15.  *     adding another digit (1, 2, or 3) onto the end of the duplicate username,
  16.  *     thus creating a unique username. When the user stops creating usernames,
  17.  *     all of the usernames and passwords are displayed on the screen.
  18.  *
  19.  * Methods:
  20.  * -------
  21.  * promptName    - Prompts for a first and last name or quit value
  22.  * randomNumber  - Generates a random number within range (1 through 3 inclusive)
  23.  * generateID    - Generates the ID using first and last name
  24.  * generatePwd   - Generates the passwords using their first name in lower case
  25.  * uniqueID      - Goes through ID list confirming each ID is unique or replacing
  26.  * displayLogins - Displays a list of all the IDs and passwords
  27.  * Main          - Reads the names, creates the login info and displays them
  28.  ******************************************************************************/
  29.  
  30. import java.util.Random;
  31.  
  32. class LoginInfoTTWSkeleton
  33. {
  34.  
  35.     /**************************************************************************
  36.      * Method Name    : LoginInfo - Main
  37.      * Author         : Terry Weiss
  38.      * Date           : January 29, 2016
  39.      * Course/Section : CSC264 - 001
  40.      * Program Description: This method will read a name entered by the user. It
  41.      *     then creates a new String with the name centered for console output,
  42.      *     and displays it.
  43.      *
  44.      * BEGIN main
  45.      *    Init location to 0
  46.      *    Clear screen
  47.      *    Display input title
  48.      *    Prompt name {prompt name method, returning name array}
  49.      *    WHILE (name is array of two elements)
  50.      *        Generate and assign ID to element in ID list {generate ID method}
  51.      *        Generate and assign password to element in Pwd list {generate pwd method}
  52.      *        Increment location
  53.      *        IF (array is full)
  54.      *            Set name to array of one element
  55.      *        ELSE
  56.      *            Prompt name {prompt name method}
  57.      *        END IF
  58.      *    END WHILE
  59.      *    Check all IDs are unique {uniqueID method}
  60.      *    Clear screen
  61.      *    Display output title
  62.      *    Display all login info {display logins method}
  63.      * END Read Name
  64.      **************************************************************************/
  65.     public static void main(String[] args)
  66.     {
  67.         //TODO Reads the names, creates the login info and displays them
  68.  
  69.     }//end method main
  70.  
  71.  
  72.     //Input methods
  73.  
  74.     /**************************************************************************
  75.      * Method Name    : LoginInfo - Prompt Name
  76.      * Author         : Terry Weiss
  77.      * Date           : January 29, 2016
  78.      * Course/Section : CSC264 - 001
  79.      * Program Description: This method will prompt for the student's first
  80.      *     name. If it's not the quit string, it'll prompt for the last name and
  81.      *     return an array of the full name. Otherwise, it'll return a
  82.      *     one-element array with quit string.
  83.      *
  84.      * BEGIN Prompt Name
  85.      *    Prompt first name
  86.      *    IF (first name isn't quit strig) THEN
  87.      *        Instantiate two-element array
  88.      *        Assign first name to element 0
  89.      *        Prompt last name to element 1
  90.      *        Return array of first and last names
  91.      *    ELSE
  92.      *        Return one-element array with quit string
  93.      *    END IF
  94.      * END Prompt Names
  95.      **************************************************************************/
  96.     private static String[] promptName(String quitString)
  97.     {
  98.         //TODO Prompts the full first and last name
  99.  
  100.     }//end method Prompt Name
  101.  
  102.  
  103.     //Calculation methods
  104.  
  105.     /**************************************************************************
  106.      * Method Name    : LoginInfo - Random Number
  107.      * Author         : Terry Weiss
  108.      * Date           : January 29, 2016
  109.      * Course/Section : CSC264 - 001
  110.      * Program Description: This method will generate a random number between
  111.      *     given min and max.
  112.      *
  113.      * BEGIN Random Number
  114.      *    Init number to 0
  115.      *    IF (min >= max) THEN
  116.      *        Set number to min
  117.      *    ELSE
  118.      *        Generate a random number between min and max and set it to number
  119.      *    END IF
  120.      *    Return number
  121.      * END Random number
  122.      **************************************************************************/
  123.     private static int randomNumber(int min, int max, Random generator)
  124.     {
  125.         //TODO Generates a random number within range (1 through 3 inclusive)
  126.  
  127.     }//end method Random Number
  128.  
  129.  
  130.     /**************************************************************************
  131.      * Method Name    : LoginInfo - Generate ID
  132.      * Author         : Terry Weiss
  133.      * Date           : January 29, 2016
  134.      * Course/Section : CSC264 - 001
  135.      * Program Description: This method will generate an ID using the student's
  136.      *     first name, last name and a generated number.
  137.      *
  138.      * BEGIN Generate ID
  139.      *    Init ID to an empty string
  140.      *    Append to ID first two letters of first name
  141.      *    Append to ID first three letters of last name
  142.      *    Generate and append a random digit between min and max
  143.      *    Return ID
  144.      * END Generate ID
  145.      **************************************************************************/
  146.     private static String generateID(String firstName, String lastName,
  147.                                         int min, int max, Random generator)
  148.     {
  149.         //TODO Generates the ID using first and last name
  150.  
  151.     }//end method Generate ID
  152.  
  153.     /**************************************************************************
  154.      * Method Name    : LoginInfo - Generate Pwd
  155.      * Author         : Terry Weiss
  156.      * Date           : January 29, 2016
  157.      * Course/Section : CSC264 - 001
  158.      * Program Description: This method generates a password by converting the
  159.      *     student's first name to lower case.
  160.      *
  161.      * BEGIN Generate Pwd
  162.      *    Return first name in lower case
  163.      * END Generate Pwd
  164.      **************************************************************************/
  165.     private static String generatePwd(String firstName)
  166.     {
  167.         //TODO Generates the passwords using their first name in lower case
  168.  
  169.     }//end method Generate Pwd
  170.  
  171.  
  172.     //Data Management methods
  173.  
  174.     /**************************************************************************
  175.      * Method Name    : LoginInfo - Unique ID
  176.      * Author         : Terry Weiss
  177.      * Date           : January 29, 2016
  178.      * Course/Section : CSC264 - 001
  179.      * Program Description: This method checks through each element of the ID
  180.      *     list, comparing the current ID with the remaining IDs. If there is
  181.      *     a duplicate, the compared ID gets changed by appending another
  182.      *     random digit.
  183.      *
  184.      * BEGIN Unique ID
  185.      *    FOR (each element left in ID list)
  186.      *        FOR (each element left in ID list)
  187.      *            IF (ID matches element) THEN
  188.      *                Append a random number in range to ID at current element
  189.      *            END IF
  190.      *        END FOR
  191.      *    END FOR
  192.      * END Unique ID
  193.      **************************************************************************/
  194.     private static void uniqueID(String[] IDList, int min, int max)
  195.     {
  196.         for (int ID = 0; ID < IDList.length - 1; ID++)
  197.         {
  198.             for (int comparedID = ID + 1; comparedID < IDList.length; comparedID++)
  199.             {
  200.                 if (IDList[ID].equals(IDList[comparedID]))
  201.                 {
  202.                     IDList[comparedID] = IDList[comparedID].append(randomNumber(min, max));
  203.                 }
  204.             }
  205.         }
  206.  
  207.     }//end class Unique ID
  208.  
  209.  
  210.     //Output methods
  211.  
  212.     /**************************************************************************
  213.      * Method Name    : LoginInfo - Display Logins
  214.      * Author         : Terry Weiss
  215.      * Date           : January 29, 2016
  216.      * Course/Section : CSC264 - 001
  217.      * Program Description: This method displays each user ID and password
  218.      *
  219.      * BEGIN Display Logins
  220.      *    Init ID to 0
  221.      *    WHILE (ID in list isn't quit value and ID is less than max length)
  222.      *        Display ID
  223.      *        Display password at ID
  224.      *        Increment ID
  225.      *    END WHILE
  226.      * END Display Logins
  227.      **************************************************************************/
  228.     private static void displayLogins(String[] IDList, String[] pwdList)
  229.     {
  230.         //TODO Displays a list of all the IDs and passwords
  231.  
  232.     }//end method Display Logins
  233. }//end class LoginInfoTTW
Advertisement
Add Comment
Please, Sign In to add comment