Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help understanding what this part does. Word is a class with some constants and methods and Dictionary is the class this part of the
Need help understanding what this part does. Word is a class with some constants and methods and Dictionary is the class this part of the code is in atm. [This is the part that explains what this does. but I have a hard time hanging with the explanation.] sortList(arg) sorts the instances of Word in theList according to the value of arg. If sortList(arg) is called for the first time, then it should attach a deep copy of theList to backup. If arg of sortList(arg) has the value of the class constant ORIGINAL, then it should (shallow) copy the address of backup to theList, set 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 sortCriterion to arg and you start off with a loop over all elements of theList. Use the method compareTo(arg) of Word to compare the instance of Word at the current position in theList to the instances in the slots with a higher index. If the result of compareTo(arg) is - 1 , you swap both instances of Word. In the end, you get a list that is either sorted by the number of count or alphabetically by the value of theWord. The elements of theList will be sorted in descending order. sortList(arg) should return "Sorted by counts" or "Sorted alphabetically" depending on the value of sortCriterion [The Code part]
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