3.2.1 Java OOPs - User

Background

Every year when the new grade nines arrive at SHDHS the site administrator must create users for every new student. A standard ASCII file can be created from the student enrollment file.(This student enrollment file is accessible only in the main office.)

This is the first of a number of classes you will be creating to complete part of a larger program.

User class.

The user class will create and store the userData in the following format:

userId, lastName, firstName, fullName

HAS-A: attributes -- All instance variable are private

userId up to four letters of the first name followed by up to four letters of the last name

firstName the user's first name

lastName the users last name

fullName the user's full name is first name space last name.

userData userId, lastName, firstName, fullName

RESPONDS-TO: methods or actions

constructor will accept one String. The String will contain information about the user in the form "lastName, firstName". Your constructor will look very much like this:

public User(String lastFirst){

initUserData(lastFirst);

}

Methods:

public String getUserData()

will return the userData

private void initUserData(String lastFirst)){

setFirstName(lastFirst);

setLastName(lastFirst)

setUserId();

setFullName();

setUserData();

}

public String toString ( )

Create a toString method that will return the userData.

private String firstFour(String name)

returns up to 4 letters of a name

this method can help setUserId() do it's work

After the User class is complete and working!

- the class will not output any data on to the screen.

- all of the methods that are called by the initUserData(String lastFirst) will be changed to private.