0/2 File Limit (b) Write the UserNane method setAvailableuserNames. The method removes from possibleNanes all names...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
0/2 File Limit (b) Write the UserNane method setAvailableuserNames. The method removes from possibleNanes all names that are found in usedNames. These represent user names that have already been assigned in the online system and are therefore unavailable. A helper method, isised, has been provided. The isused method searches for name in arr. The method returns true if an exact match is found and returns false otherwise The example below shows the intended behavior of the setAvalableuserNames method. Strings in possibleNanes after statement execution Statement Stringl) used ("harta", "harte", "harty"): "harta", "hartma", UserName person2 - new UserName ("nary", "hart"): "hartmar", "hartnary" person2.setavallableuserNanes (used); "hartma", "hartnar", "hartmary" Assume that the constructor works as specified, regardless of what you wrote in part (a). You must use isused appropriately to receive full credit. Complete the setAvailableuserNanes method below. ** Renoves strings from possibleNanes that are found in usedNanes as described in part (b). public void setAvailableuserNanes (Stringl) usedNanes) public class UserName // The 11st of possible user names, based on a user's first and last names and initialized by the constructor. private ArrayList<Strings possibleNanes; /* Constructs a UserName object as described in part (a). * Precondition: firstName and lastNane have length greater than e * and contain only uppercase and lowercase letters. public UserName(String firstNane, String lastNane) ( /* to be implenented in part (a) /) /* Returns true if arr contains name, and false otherwise. / public boolean isused(String name, String[] arr) (* inplenentation not shown /} ** Removes strings from possibleNanes that are found in usedNanes as described in part (b). public void setAvailableuserNames (Stringt) usedNanes) { to be ieplenented in part (b) "/) (a) Write the constructor for the UserName class. The constructor initializes and fils possibleNames with possible user names based on the firstNane and lastNane parameters. The possible uner names are obtained by concateniating lastNane with different substrings of firstNane. 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 firstNane. The following example shows the contents of possibleNanes after a UserNane object has been instantiated. Example Type here to search 0/2 File Limit (b) Write the UserNane method setAvailableuserNames. The method removes from possibleNanes all names that are found in usedNames. These represent user names that have already been assigned in the online system and are therefore unavailable. A helper method, isised, has been provided. The isused method searches for name in arr. The method returns true if an exact match is found and returns false otherwise The example below shows the intended behavior of the setAvalableuserNames method. Strings in possibleNanes after statement execution Statement Stringl) used ("harta", "harte", "harty"): "harta", "hartma", UserName person2 - new UserName ("nary", "hart"): "hartmar", "hartnary" person2.setavallableuserNanes (used); "hartma", "hartnar", "hartmary" Assume that the constructor works as specified, regardless of what you wrote in part (a). You must use isused appropriately to receive full credit. Complete the setAvailableuserNanes method below. ** Renoves strings from possibleNanes that are found in usedNanes as described in part (b). public void setAvailableuserNanes (Stringl) usedNanes) public class UserName // The 11st of possible user names, based on a user's first and last names and initialized by the constructor. private ArrayList<Strings possibleNanes; /* Constructs a UserName object as described in part (a). * Precondition: firstName and lastNane have length greater than e * and contain only uppercase and lowercase letters. public UserName(String firstNane, String lastNane) ( /* to be implenented in part (a) /) /* Returns true if arr contains name, and false otherwise. / public boolean isused(String name, String[] arr) (* inplenentation not shown /} ** Removes strings from possibleNanes that are found in usedNanes as described in part (b). public void setAvailableuserNames (Stringt) usedNanes) { to be ieplenented in part (b) "/) (a) Write the constructor for the UserName class. The constructor initializes and fils possibleNames with possible user names based on the firstNane and lastNane parameters. The possible uner names are obtained by concateniating lastNane with different substrings of firstNane. 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 firstNane. The following example shows the contents of possibleNanes after a UserNane object has been instantiated. Example Type here to search
Expert Answer:
Answer rating: 100% (QA)
Note I have added an additional method print which is not mentioned in the question but it is required to show that the program is working fine I have ... View the full answer
Related Book For
Systems analysis and design
ISBN: 978-0136089162
8th Edition
Authors: kenneth e. kendall, julie e. kendall
Posted Date:
Students also viewed these programming questions
-
For the list of possible sample means that you produced in Exercise 53. a. Once again show the table and the bar chart for the sampling distribution and comment on the shape of the distribution. b....
-
If on object has a greater speed than a second object, does the first necessarily have a greater acceleration? Explain, using examples.
-
If your last name begins with the letters A L, read and brief the following cases: a. Sorensen, T. C. Memo. 1994-175 b. Keller, 84-1 USTC 9194. If your last name begins with the letters M Z, read...
-
If possible, completely factor the expressions in Problems 336. 9-x-2x
-
Let f be defined on [a, b], and let the nodes a = x0 < x1 < x2 = b be given. A quadratic spline interpolating function S consists of the quadratic polynomial S0(x) = a0 + b0(x x0) + c0(x x0)2 on...
-
As shown in Fig. 16-2, two flasks are connected by an initially closed stopcock. One flask contains krypton gas at 500 mmHg, while the other contains helium at 950 mmHg. The stopcock is now opened so...
-
What is air-conditioning? What is comfort air-conditioning?
-
A large profitable corporation is considering two mutually exclusive capital investments: Alt A Alt B Initial cost $11.000 $33,000 Uniform annual benefit 3,000 9,000 End-of-depreciable-life 2,000...
-
A soft tennis ball is dropped onto a hard floor from a height of 1.95 m and rebounds to a height of 1.56 m. (Assume that the positive direction is upward.) (a)Calculate its velocity (in m/s) just...
-
A business manufactures refrigerators for domestic use. There are three models: Lo, Mid and Hi. The models, their quality and their price are aimed at different markets. Product costs are computed...
-
Plot the characteristics: IDD versus Vin for CMOS inverter. Clearly indicate the quiescent current, peak current and mid-point voltage. Explain the charging and discharging mechanism of a CMOS...
-
Early in its fiscal year ending December 31, 2024, San Antonio Outfitters finalized plans to expand operations. The first stage was completed on March 28 with the purchase of a tract of land on the...
-
Kinette, age 16, has dividend income of $2,800 and interest income of $935. She has no investment expenses. Determine the net unearned income for the purpose of the kiddie tax.
-
Pharoah Company reported the following amounts for 2022: Raw materials purchased $95,200 Beginning raw materials inventory 5,824 Ending raw materials inventory 5,040 Beginning finished goods...
-
1. You currently owe $18,000 on a car loan at 8.0% interest. If you make monthly payments of $576.49 per month, how long will it take you to repay the loan? Please state the time in months. 2. You...
-
write down the definitions for the following terms. (1) International Business Law: (2) Continental Law: (3) Strict liability: (4) Endorsement: (5) Arbitration: answer the following questions. (1)...
-
A 43 inch long steel shaft is subjected to a torsional load of 1549 in-lbf. If the shaft has a radius of 0.4 inches, what is the estimated angle of twist to two decimal places in radians? Given...
-
Define relevant costs and discuss: (1) whether all future costs are relevant for decision making and (2) whether variable costs are always relevant and fixed costs are always irrelevant
-
Define what is meant by a prototype that is a model with some, but not all, essential features.
-
Define the term function code.
-
Examine the interview structure presented in the sequencing of the following questions: 1. How long have you been in this position? 2. What are your key responsibilities? 3. What reports do you...
-
Entrepreneur magazine ranks franchises. Among the factors that the magazine uses in its rankings are growth rate, number of locations, start-up costs, and financial stability. A recent ranking listed...
-
The following 20 observations are for two quantitative variables, x and y. a. Create a scatter chart for these 20 observations. b. Fit a linear trendline to the 20 observations. What can you say...
-
Blatt Consulting Services is interested in comparing the number of customer accounts managed by its consultants. The chart below is a default chart produced in Excel. a. Which preattentive attributes...
Study smarter with the SolutionInn App