QUESTION

§ In BlueJ, create “New Project” namedLASTNAME-companyUse good programming style and Javadoc documentationstandards...

§ In BlueJ, create “New Project” namedLASTNAME-company

Use good programming style and Javadoc documentationstandards

Create a “New Class…” named Company tostore the employee mappings of employee names (Key) to employee ids(Value)

Declare and initialize class constantsMIN and MAX toappropriate values

Declare and instantiate a RandomrandomGenerator field object

Declare a String field namedname for the company’s name

Declare a HashMap<String,String> field namedemployees

Add a constructor with only 1 parameter namedname and:

Assign name field toname parameter after trim, uppercase& replaceAll   (1 or more ANY white space regularexpression with just 1 single space)

Initialize employees field by creatingan instance of that object

Add accessors getName( ) andgetEmployees( )

Add accessor getTotalNumberEmployees() to return the total number of mappings in thecollection of the employees field

Add formatString(String origString) toreturn a formatted origString after trim,uppercase, and replaceAll in between white spaces (with singlespace)

MUST first check if origString is null(which just returns an empty String)

Add method String generateId(Stringname) to return the employee id generated by takingthe first letter of each word in nameparameter AND adding a random 3-digit integer between100-999 (inclusive of both ends)

MUST .split the parametername into a String[ ]nameArray with regex taking into accountmultiple white spaces in between words inname

MUST use a for loop to get the firstletter in each word in nameArray

MUST use class constants MIN &MAX (NO hard-code) to generate (using.nextInt) the random number used for theid in the range [MIN – MAX]

Add addEmployee(String inputName)& removeEmployee(String inputName)both with void returns and:

Check if (trimmed) inputName is emptyor null, print “Name is INVALID”

MUST use formatString forinputName (remember Strings areimmutable)

MUST use .containsKey to see ifinputName key exists inemployees and:

Print “Existing: <name>” (ifname already exists for addEmployee)

OR …“Non-existing: <name>” (ifnon-existing for removeEmployee)

MUST use generateId (foraddEmployee) to generate employee id to.put

MUST print heading with name & id, if employee add/delete issuccessful

Add void removeIds(String id) toremove ALL mappings in employees wherethe value matches the id search parameterand:

MUST use a local variable to keep track if a match wasfound

MUST also have check if id parameteris null or empty

MUST use formatString to format theid input parameter

MUST use a for loop,.keySet and.iterator to iterate thru allemployees

Check if each employee id value is equal (ignoring case) to thesearch id

MUST use the Iterator.remove to removeid matching mappings

MUST print heading with name & id for EACH removedemployee

Only after the entire search is completed (THUS … outside ofloop), check if no matches found andprint “NO employees with id:<id>”

Add void listEmployees() to print ALLemployee names (Key) & ids (Value):

MUST always print the heading “Employees for<name>:”

MUST use getTotalNumberEmployees or.isEmpty to check if NO entries inemployees exist and prints“NOemployees”

MUST use a for-each loop and.keySet to iterate thru allemployees

MUST print employee in format“     <name> :<id>” (w/ leading spaces)

Public Answer

M7OHHU The First Answerer