Assignment2 Solved

30.00 $

Categories: ,

Description

The LinkedIn Command Line Interface Class

Package: edu.sinclair

LinkedInUser

1) Add two additional private member variables to the LinkedlnUser class:

// holds the last date/time that this user in

java. util. Date lastLogLnDate;

// holds the number of times this user has Logged in

int LoginCounter;

2) Add and implement the following public methods to the LinkedlnUser class:

/**

*Increments the number of times this user has lagged in and assigns today’s

*date to the last Login date.

**/

public void incrementLoginCounter ( ) {

}

// hint: to assign today’s date to a Date type variable, simply create a new

// instance of Date today = new Date ( ) ;

/**

*Returns the number of times this user has Logged in

*@return the login counter.

 

Public int getLoginCounter ( ) {

}

/**

*Returns the Date that this used last logged in.

*@return the Date.

public Date getLastLoginDate ( ) {

}

LinkedlnCLl

Create a class called, LinkedlnCLl which will serve as the command line interface between the

user and your software. Define the following properties.

/**

*Holds the list of users in the system.

Private List <LinkedInUser> users ;

/**

*Holds the logged in user.

Private LinkedInUser loggedInUser;

Public   LinkedInCLI() {

Users – new ArrayList <> ();

}

The LinkedlnCLl class should have methods to list all the users (i.e. print out their usernames), sign up a new user, delete a user, print who the logged in user is, sign off, and quit.

Create a public static void main method which prints the following menu to the console and awaits user input. Upon entry the application should do the following:

a) Load any previously saved data. See the Serializing and Deserializing section below for the details

b) If there are no users in the system, do the following

  1. Prompt the user to establish the root user and password.
  2. Default the Linkedlnuser type to “P” for premier and call the newly added incrementLoginCounter () method to establish that this user has logged in once.
  3. Add the newly created user to the list of users defined within the constructor.
  4. Assign the newly created user to loggedlnUser property on the class to indicate that this new user is the logged in user.
  5. Display the Welcome menu (step 2 below).

c) If there is at least one user in the system, do the following

  1. Prompt the user to login by supplying a user name and password.If the user name doesn’t exist, display the message, “There is no user with that user name” and re-display the login prompt.
  2. If the user does exist and the password is incorrect, display the message, “Password mismatch” and re-display the login prompt.
  3. If both username and password are valid
  4. Call the newly added incrementLoginC0unter() to increment the number of times this user has logged in
  5. Assign the user to loggedlnUser property on the class to indicate that this is the logged in user. display the Welcome menu (step 2 below).
  6. Please login to continue.

    User name

    doug

    Please supply the users’ password

    doug

    1. Display the Welcome menu.

    Welcome logged in user name

    List all Users,

    Sign up a New User,

    Delete a User,

    Who am I

    Sign Off

    Quit

    (substitute the actual logged in user name for the logged in user name text).

     

Menu Options

List all Users

Loop through all the Linkedln users and print their user name to the console.

 

Sign up a New user

  • Prompt the user for the user name to add. Check if the supplied user name already exists in the users list. If it does, display an error message to the console and re-display the menu.
  • If the supplied user name is unique, do the following
  • prompt the user to enter a password and what type of user he/she is
  • Valid types are “S” for Standard and “P” for Premier. If the user enters any other value, display the message, “Invalid Valid types are p or S” and redis I the menu.

Enter a username

Enter a password

Enter the type Of user (P or S)

Invalid user type. Valid types are P or S

  • Construct a LinkedInUser instance and add the instance to the users list on the LinkedInCLI class.
  • Serialize your list Of LinkedInlJser Objects to save the newly added user.
  • Afterwards, re-display the menu.

Delete a User

  • Prompt for the user name to delete. Check if the supplied user name exists in the user
  • If the user does NOT exist, display an error message to the console and re-display the menu.
  • If the user does exist, prompt for the password of the user being deleted.
  • If the password is not correct, display an error message to the console and re-display the menu.
  • If the password is correct, remove the user from the users list. Serialize your list of Linkedlnuser Objects to save the new list, and re-display the menu.
  • If the deleted user was the logged in user, null out the loggedInUser on the LinkedInCLI class and represent the user interface.
  • Since the logged in user is now null. the application should act the same as the application did upon Start up (either making the user establish a root user or login with an existing user). See step I b.
  • Who am I

    Display the following logged in user information

    o The username

    o The user

    o The last logged in date/time. Use the java. text.SimpIeDateFormat class to format the date/time to be printable.

    o The login count

    last:nggedInDate

    Logged In:

    Sign a user

    Sign OFF

    Last In: zmg-øl-zz

    Sign off

    • Null out the loggedlnUser property and re-present the user interface.

    Since the logged in user is now null, the application should act the same as the  application does upon Start up (either making the user establish a root user or login With an existing user). See step I b.