3.2.4 Java OOPs - UserList

This will class will use the Java's Collection Framework ArrayList to store all the users (studnets id's and passwords).

Before you start, look at the Java Array List note and sample code.

UserList

To Start, this class will be responsible for the following actions
  • given a user in the form lastname, firstName
    • it will add the user to the list
  • display the list of users on the screen -- add a toString() method

HAS-A
private ArrayList<User> uList
  • the list that will hold all of the users
  • the <User> tells java that the ArrayList will contain objects made up by the User class

Constructor
will create the empty uList ArrayList; completed for you below

RESPONDS-TO
add(String userData)
  • this method will create a new user and add this user to the list
setAllPasswords()
  • for each user in the list, a password is set
  • Make sure you see the for each loop in the Java Array List note and sample code
  • this method should be called only after all users have been added to the list
  • each time this method is called, all passwords in the list are set to a new value
toString()
  • will return all users in the list based on the user's toString() method
  • each user will start on a new line.

After you have finished this Phase, you should be able to add as many users as you want through the workbench and set their passwords.

The outline of this class is as follows:


Comments