Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I got task 1 done. need help with how to proceed with task 2, how to write the new Class Dictionry. Check below for

Hi, I got task 1 done. need help with how to proceed with task 2, how to write the new Class Dictionry. Check below for two pictures. one of Task 2 instructions and the already given Class Word. highlighted blue is important.

[The task]

image text in transcribed

[class Word]

image text in transcribed

3 Task 2: The class Dictionary The instanee variables of this class are thelist and becksp. You initialise bucksp to null when you doclare it. thelist is inktialiasd in the constructoe. addString(arg) talos in the string arg. If arg is not yet coetalesd in any elcment of theLiat, then addString(arg) creates a new instance of Word with a value cownt 1 and adds it to the List. If there is already an instance of Word with a vilue of the Word equal to arg, then it increases its vilue of cownt by 1 . Uoe caly the methods listed in the class diagram of Word (doa't implement a metbod that changes emant). sddString(Stringl ghould return the return sulue of toStringl? of the added or updated instance of Word. sorthist(arg) sorts the instaness of Word in theList aceording to the value of arg. If sorthist(arg) bs callod for the first time, then it should attach a derp copy of the List to backip. If arg of sortList(arg) has the value of the class coestant ORIGINAL, then it should (shallow) copy the address of backup to theList, get the value of sortCriterion to that of ORIGINAL, and return "Word list was reset". If arg has the value of one of the other class constants, then you set sortCriferion to arg and you start of with a boop ower all clements of the List. Use the method compare To (arg) of Word to compare the instance of Word at the current position in theList to the instaness in the slots with a higher index. If the ressult of compareTo(arg) b -1, you swnp both instanoss of Word. In the end, you get a list that is either sorted by the number of count or alphabetically by the value of the Word. The elements of thelist will be sorted in desecnding order. sortList(arg) should return "Sorted by counts" or "Sorted alphabetimlly" depending on the value of sortCriterion. 2 netar Word(arg) checks if theList has an instanse of Word at the slot with the index arg. If ary excoerls the largest index of theList, the method should return "end". Otherwisc, it should return the return value of taString() of that instanee of Word. foString() should return a string that starts with "Content: " followed by a lise break. It should call the to\$tring() methods of all clements of theldist and concatenate their return strings to one large string. There should be a lise break between each. The method should retum the coecateanted string

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions