Question: java main AP CS A UserName FRO This question involves the creation of user names for an online system. A user name is created based

java main AP CS A
java main AP CS A UserName FRO This question involves the creation
of user names for an online system. A user name is created
based on a user's first and last names. A new user name
cannot be a duplicate of a user name already assigned. You will
write the constructor and one method of the UserName class. A partial
declaration of the UserName class is shown below. public class User Name

UserName FRO This question involves the creation of user names for an online system. A user name is created based on a user's first and last names. A new user name cannot be a duplicate of a user name already assigned. You will write the constructor and one method of the UserName class. A partial declaration of the UserName class is shown below. public class User Name 77 The 1st 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) *Y 1 /** 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) 1 / to be implemented in part (b) */ } (a) Write the constructor for the Userblame ructor for the s l ags The constructor initializes and fills possibleNames bleNames with possible usernames based on the ErstName and lastName parameters The possible user names are obtained by concatena in lastName with different substrings of firstName. The substrings begin with the first chara 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 LeNames after a UserName object has been The following example shows the contents of possibleNam instantiated. Example UserName Person new serName ohn" "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","smith joh", "smithjohn" Write the UserName constructor below. /** Constructs a User Name 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 last Name) (b) Write the UserName method setAval. me UserName methodet AvailableUserNames. The method removes from 1bleNames 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, isused, 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 set.AvailableUserNames method. Statement Strings in possibleNames after statement execution String[] used - ( "harta", "hartm", "harty"); User Name person2 = new "hartm","hartma", UserName ("mary", "hart"); "hartmar","hartmary" person2.setAvailableUser Names (us "hartma", "hartmar", ed); "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 setAvailableUserNames method below. /** Removes strings from possibleNames that are found in usedNames as described in part (b). public void setAvailableUserNames (String[] usedNames) war Schedule FRO Val The method returns the con involves the scheduling of car repairs. The classes used in the question are used to information about car repairs. The methods shown and the methods to be written involve the anc performing a repair and the bay in which the repair takes place. A bay is an area of a report shop which a car is parked while a mechanic performs a repair Mechanics and bays are identified by fequential integer identification numbers that start with removeVariety method updates the master order by removing all of the go ch the variety of cookie matches the parameter cookie Vet The master Order d ers in or more cookie orders with the same variety as cookie Var. The method retur contain ber of boxes removed from the master onder sample consider the following code coment ter Order goodies - new MasterOrder) di addorder new Cookieorderchocolate Chip dies. addorder new cookieorder b read )) dies.addorder new cookieOrder Nacaroon". 2)) dies. addorder the cookieorderchocolate chip". 3)) the code segment has executed, the contents of the matter order are as shown in ang table om in the Chocolate Chip" "Shorthead" "Macareca" "Chocol Andividual car repair is represented by the following arrapai cias le class Car Repair Private int bayan publie Car Repairint m thod call goodies.removeVanety chocolate chorus 4 because there were two ate Chip cookie orders totaling 4 boxes. The master order is modified as show int b) nechanie bayu - b; - Shortbread "Macaroca nod call goodies.removeVariety Brownie) returns 0 and does not change the publie int getMechanie return wechanicum method removeVariety below. public int get Bayu return baytun noves all cookie orders from the master order that have the same variety of kie as cookie Var and returns the total number of boxes that were removed aram cookievar the variety of cookies to remove from the master order eturn the total number of bates of cookieVar in the cookie orders removed There may be other instance variables, constructors and methods to Shown. sad int removeVariety string cookie Var) The following Repairchedule class represents the use of bays by mechanics repairing cars. You will write two methods of the Repair Schedule class. public class Repair Schedule ** Bach element represents a repair by an individual mechanic in bay. */ private ArrayList

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 Databases Questions!