Question
Use Javadoc documentation standards (comments & tags) and good programming style (10) Suppose a Company class has a name of String object type and group
Use Javadoc documentation standards (comments & tags) and good programming style (10)
Suppose a Company class has a name of String object type and group (collection) of employees where each employee name (Key) is mapped to an employee id (Value):
The employee name of String object type is always stored in uppercase with ALL extra spaces (leading, trailing and multiples spaces in the string) removed
The employee id of String object type is the first letter of each word in the name along with a random 3-digit number between 100 999 (inclusive of both ends) (e.g.,
Declare and initialize class constants MIN = 100 and MAX = 999. (1)
Declare a Random randomGenerator field. (1)
Define a constructor that takes one parameter named name and (3) Assign name parameter to name field (HINT: use String methods .trim, .toUppercase & re- placeAll (replace 1 or more ANY white space regular expression with just 1 single space)) Initialize employees field by creating an instance of that object Initialize randomGenerator field by creating an instance of that object
Define accessor methods getName() and getEmployees() to return the appropriate fields. (2)
Define an accessor method getTotalNumberEmployees() to return the total number of mappings in the collection of the employees field. (1)
Define a method with the header private String formatString(String origString) to return a for- matted origString after applying .trim, .toUppercase, and .replaceAll in between white spaces (with single space) to origString. (HINT: MUST first check if origString is null (which just returns an empty String)) (2)
7. Define a method with the header private String generateId(String name) to return the employee id generated by taking the first letter of each word in name parameter AND adding a random 3-digit integer between 100-999 (inclusive of both ends) (4)
.split the parameter name into a String[ ] nameArray and take into account multiple white spaces in between words in name
use a for-each loop for (String word: nameArray) {
...
}
and .substring(0,1) to get the first letter in each word in nameArray
use class constants MIN & MAX (NO hard-code) to generate (using .nextInt) the 3-digit random number in the range [MIN MAX] 8. Define two methods with headers public void addEmployee(String inputName) & public void removeEmployee(String inputName) to add and remove
after the entire search is completed (outside of loop), check if no matches found, then print NO employees with id:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started