Answered step by step
Verified Expert Solution
Question
1 Approved Answer
EXERCISE: Implement the following Project, +dalstsAUatartint, end: it, itsm chat): void and Test Main cla5s) as described in the UML dig. Below This field represents
EXERCISE: Implement the following Project, +dalstsAUatartint, end: it, itsm chat): void and Test Main cla5s) as described in the UML dig. Below This field represents String objects as an Arrayist of wrapped characters Initialize the field by assignment of the parameter All occurrences of the given character from start index to end index are removed from glist, start included end not included; illegal indices are ignored if nosition is legitimate Index, the Arndist element at position is replaced by item; the Fied ist: AtavLst Character> replace group (overloaded): + replace( position-int, item: charl oid method calls the setlposition, item method of text: Strin text. char Instantiates the field by assignment of the parameters As abowe replaccistart: int. sodio, item: type): void four more overloaded copies with the following types for item perameter: MStringBuilder String char Arraist As above, jput validation applies for pasition Hints: In each method delete the elerments from start to end, then insert item at stert ust for the sake of our book; the method is identical to the first tantiates the field to the length 'size De ault constructor nstantiates a char array to the field length, losds the field elements nto the array and returns the result converts the character sequence of the field into a String object and returns the resul. Hint: use the previous method and the elusai(ltem) method of the String class sultably chaosing the parameter item. Other implementations are also accepted for +tbrAtiIposition: int, item: char): void String methods group lincompletel: +charAtiposition returns the character element of ct st the given position indsOfitarget: char): iot tindesofitarget: String)nt Methods-Instance methads Initial group lace method above char char runs a search for the character target, returns the index of its first occurrence if taret found, otherwise returns-1 use the consertostrinemethod then the indexOf(String method of the String class applies +teStrinal String calls the teSio) methed with respect to the field and returns the value; note that this methad does nat convert your object to a The Test class containing the main method is designed to test all the methods you defined in the MyStrineEuilder class. 1. Test the constructors first. Check the instantiated MystrineRuilder objects applying console printings Constructor testing should at the same time test your teSrine I method. All constructor test prints should also show the size of the field. 2. Test the toArar seosentSting( ) and equals() methods (initial eroup) 3. Test the append group 4. Test the insert group 5. Test the delete group 6. Test the replace group 7. Test the String class group 8. Every test result printed to the console together with an explanation message must also be copied to test dacument sppended after the Test class code as a large comment block. Make it easy to your grader to understand and verify your testing process alls squals with respect to the corresponding fields and returns the other im ntations also acc sdds the gven character to append group (overloaded): tappend litem:charL wid +append litem: charlwoid appendlitem: type vold edds the ziven character to Three more averloaded copies with the following types: MyStrinBuilder String charl 1 Hints: use the adAWATeyst other ] methad of the Arraxist class (not discussed in the book) which appends another list to this list, for String and charl types use the corresponding MsstriBulesr constructors which instantiate for you the lists to be appended. Other implementetions using loops for sppending indvidual characters sre also accepted. Note: in the Stineuilder class the append method has 14 overloaded copies. So0, be happy with the four abave inserts the grven character item to Shis at the given position; the method validates the position value to be between 0 and list length f the position is legitimate, the add position, item method of the Insert) group(overloaded]: +insert (position: int, item:char)void class is called, otherwise item isappended to the li tinsert [position: tem: type! i void four more averloaded copies with the followinR types for item parameter: Mesnae@wider strine char! rrayList As above. position jput validstion app es Hints: use the sdAlWiot pasition, Acravlist other methed of the Aclass (not discussed in the book) which inserts another list into this list starting at the given position; as in the append case, for String and charl] types you need the corresponding MString Builder constructors to instantiate the ists to be appended, Other implementations using loops for oneby one insertion of individual characters are also accepted. the elements from start index to end index are removed from gst Delete) group: +deletelstart: int, end: it) oid udedi illega
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