Skip to content

Rkthompson/java-account-creator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

java-account-creator

AppDemo.java and Account.java are a simple example of class instantiation and functions in Java.

When AppDemo is run it will use Account.java and create a new user account object.

  • First and last name values are passed to Account.java from AppDemo.java.
  • The constructor then calls the following to populate the remaining object attributes.
        //ask user for department entry
        setDepartment(askForDepartment());

        //set password
        setPassword(randomPasswordGen(defaultPasswordLength));

        //set email
        setEmail(buildEmailAddress(firstName, lastName, domainName, topDomain));

        //set userName
        setUserName(buildUserName(getFirstName(), getLastName()));

        //write to terminal account creation values
        displayAccountDetails();

askForDepartment uses a flag controlled do...while loop to validate terminal inputs when the user selects a department.

randomPasswordGen uses the SecureRandom class to create a random password from a String of possible characters.

buildEmailAddress will populate the email address attribute by concatenating the passed values.

setUserName will populate the user name attribute with the first initial of the first name plus the last name.

displayAccountDetails prints to terminal the new account configuration.


AppDemo.java will then use the newly created object to call the setters setAlternativeEmail and setMailBoxCapacity to change their values.

Finally, displayAccountDetails is called again to print to terminal the updated account details.

About

AppDemo.java and Account.java are a simple example of class instantiation and functions in Java.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages