subject
Advanced Placement (AP), 20.02.2020 17:45 yialefi

Public class UserName
{
// The list of possible user names, based on a user’s first and last names and initialized by the constructor.

private ArrayList possibleNames;
/** Constructs a UserName object as described in part (a).
* Precondition: firstName and lastName have length greater than 0
* and contain only uppercase and lowercase letters.
*/

public UserName(String firstName, String lastName)
{ /* to be implemented in part (a) */ }

/** Returns true if arr contains name, and false otherwise. */

public boolean isUsed(String name, String[] arr)
{ /* implementation not shown */ }

/** Removes strings from possibleNames that are found in usedNames as described in part (b).*/

public void setAvailableUserNames(String[] usedNames)

{ /* to be implemented in part (b) */ }

}
a. Write the constructor for the UserName class. The constructor initializes and fills possibleNames with possible user names based on the firstName and lastName parameters. The possible user names are obtained by linking lastName with different substrings of firstName. The substrings begin with the first character of firstName and the lengths of the substrings take on all values from 1 to the length of firstName. Example: firstName: "John" lastName: "Smith". After the code segment has been executed, the possibleNames instance variable of person will contain the following String objects in some order. "smithj", "smithjo", "smithjoh", "smithjohn"

b. Write the UserName method setAvailableUserNames. The method removes from possibleNames all names that are found in usedNames. These represent user names that have already been assigned in the online system and are therefore unavailable. The helper method isUsed has been provided and is properly implenented, and must be used. The isUsed method searches for name in arr. The method returns true if an exact match is found and returns false otherwise.
statement: String[] used = {"harta", "hartm", "harty"};
statement: UserName person2 = new UserName("mary", "hart");
possibleNames after statement execution: "hartm", "hartma", "hartmar", "hartmary"
statement: person2.setAvailableUserNames(used) ;
possibleNames after statement execution: "hartma", "hartmar", "hartmary"

ansver
Answers: 1

Another question on Advanced Placement (AP)

question
Advanced Placement (AP), 23.06.2019 19:20
Do you want free brainliest and free points? answer this drivers ed question correctly and ill give you both : ) how can you count following distance? a. look for a moving object and count the seconds it takes for you to pass it after the car you are following has passed it. b. look for a stationary object and count the seconds it takes for you to pass it after the car you are following has passed it. c. look for the rear wheels of the car in front and count the number of rotations. d. look for the stripes on the road and count them as you pass by.
Answers: 2
question
Advanced Placement (AP), 24.06.2019 17:10
What would be the problems if the constitution had limited the position of justice to 10 years? why?me , idc if you don’t have the accurate answer , just tell me your guess
Answers: 1
question
Advanced Placement (AP), 24.06.2019 19:00
Melissa is fearful of men and refuses to go on dates. her therapist suggests that she is fearful because she was sexually abused when she was young. the therapist's suggestion most clearly reflects a perspective. a.) humanistic b.) behavioral c.) biological d.) psychoanalytic e.) sociocultural
Answers: 1
question
Advanced Placement (AP), 25.06.2019 05:00
Mars has a surface gravity that is only 0.38 (a little over one-third) that of earth's. thus, the weight of an object will also be 0.38 times that of earth. what is the g.p.e. of a climber who weighs 675 newtons on earth at the top of 26,000-meter olympus mons?
Answers: 1
You know the right answer?
Public class UserName
{
// The list of possible user names, based on a user’s first and...
Questions
question
Computers and Technology, 18.05.2021 07:30
question
Mathematics, 18.05.2021 07:30
question
Mathematics, 18.05.2021 07:30
Questions on the website: 13722363