Question: Implement the static method generateElements declared as follows: / * * * Generates the set of characters in the given { @code String } into

Implement the static method generateElements declared as follows:
/**
* Generates the set of characters in the given {@code String} into the
* given {@code Set}.
*
* @param str
* the given {@code String}
* @param charSet
* the {@code Set} to be replaced
* @replaces charSet
* @ensures charSet = entries(str)
*/
private static void generateElements(String str, Set charSet){...}
Informally, generateElements extracts the characters from the given String and puts them in the given Set. Note that there is no requires clause to rule out repeated characters in str and that charSet is a replaces-mode parameter.
Implement the static method nextWordOrSeparator declared as follows:
1/**
2* Returns the first "word" (maximal length string of characters not in
3*{@code separators}) or "separator string" (maximal length string of
4* characters in {@code separators}) in the given {@code text} starting at
5* the given {@code position}.
6*
7* @param text
8* the {@code String} from which to get the word or separator
9* string
10* @param position
11* the starting index
12* @param separators
13* the {@code Set} of separator characters
14* @return the first word or separator string found in {@code text} starting
15* at index {@code position}
16* @requires 0<= position <|text|
17* @ensures

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!