Assignment 4: Dictionary
Logistics The assignment is meant to be done individually.The deadline for this assignment is 11:59 PM on Dec 2, 2024, Pacific Time.Academic dishonesty is unacceptable and will not betolerated in this course.Last Modified: Nov 15, 2024
General Description
In this assignment, you need to build a dictionary application using Swing. The application has the following features. Users can:add new words, new meanings to the wordsreplace an old word with a new one, without changing its original meaning and its frequencyremove words from the dictionary and check if a word is in the dictionarycount the frequency of searches for each word.display the most frequent words based on the prefix they provide.display the search historyImport and export words in batchIn detail, your dictionary should have the following functionalities:Users should be able to add, remove and modify words.Users should be able to check if a certain word is in the dictionary and retrieve its meaningsUsers should be able to see the three most frequent words that can complete their given keyword.e.g., for uni , it should return universe , university , universal .e.g., for apple , Input format:Output format:For export, please export the words in the (descending) order of frequencyWe ensure that no word will have the same frequency in grading test cases.Exception Handling
In this assignment, you need handle 4 kinds of exceptions:InvalidWordError : the word entered to add/find/clear is not a worBy mentioning word , we define it as a String consisting of a-z and A-Z
WordNotFoundError : the word is not found in our dictionary.WordDuplicatedError : the word to be added has existed in the dictionary.FileNotFoundError : the file path provided does not exist when importing or exporting from a txt file.
Definition of Exceptions
In order to raise those 4 exceptions, please define them by inheriting the RuntimeException class.Once needed, you need to:you need to:First, throw the related exceptionThen,display texts to notify that an error has occurred.Notice: For grading, we will test only one error for each exception-handling test case.
Layout Example for Dictionary
Recommended Procedure for Implementation
- Create a project named Dictionary
- Create a package under src named Dictionary
- Create a form under packagewith the name. Check create bound class 3. Create a form under package Dictionary with the name Dictionary.form . Check create bound classand it will automatically createDictionary.javaOn Dictionary.form , design the GUI of Dictionary. In particular, you should (at least) have the followingcomponents as you can see in the figure we show above:
- FINDButton
Note: only increase the frequency counts of the top 3 words.The words feasible to be searched should include the keyword.Display the top 3 (or 2 or 1) words in the TextFreqWord1 , TextFreqWord2 , TextFreqWord3fields in the (descending) order of frequencyIf there are fewer than 3 words to display,please leave those TextFreqWord fields empty.
- ADDButton
- MODIFYButton
Note: replace the old word with the new one, but keep its original meaning and frequency.
- REMOVEButton
- CLEARButton
- IMPORTButton
- EXPORTButton
- TextNewWord : where you type in the word you want to add/find/remove
- TextOriginalWord : where you type in the frequency you want to modify
- TextFreqWord1 , TextFreqWord2 , TextFreqWord3 : 3 TextFields to display frequent words in findingprocedure
- TextArea : where:
- word meanings are displayed
- error messages are displayed
- searchHistoryList : a JList where show the search history
- xTextFilePath : where you type in the path of import ot export
Be careful: The names of the components should be the same as showed above. Don't forget to
consider and handle 4 self-defined exceptions during implementation!
- Define 4 self-defined exceptions mentioned above using inheritance of RuntimeException .
- Implement the Action Listens for all the buttons.
- Test your code and see if the GUI works smoothly and has the expected functionality.
SampleTest Please notice that SampleTest is just to help you understand the whole assignment more easily. Sample tests
are only for clearer explanation and simple testing during your implementation. Passing all the sample tests are only for clearer explanation and simple testing during your implementation. Passing all the sample testsdoes not mean you will get a full score. You need to read the description carefully, and think it
comprehensively when implementing this assignment.After you complete the assignment following the recommended procedures listed above, you could thefollowing SampleTest code to test if your implementation 代寫Dictionary application using Swing workssmoothly:package Dictionary;You could find input.txt and output_ref.txt mentioned in SampleTest on Canvas.To run the SampleTest , you may need to change all the attributes into public instead of private .Submission During implementing this assignment:
Please follow the steps in general description A simple way to check if you are following the steps is to run the sample tests. If every sample test runssmoothly and gets passed, then you are fine.Fail to obey this rule may lead to reduction of your final score!
You need to submit your hw on both Gradescope and Canvas.You need to submit a JAR on Gradescope file for autogradingAfter you complete this assignment, zip up this project folder into Dictionary.zip . After yougenerate the JavaDoc, also put a screenshot of the JavaDoc in the zip file. Please do not submit .rar file. Then upload it to Canvas under Assignment 4 submission linkTo build the JAR file, please follow:Create an artifact configuration for the JARFrom the main menu, select File | Project Structure and click Artifacts.Click +, point to JAR and select From modules with dependencies.To the right of the Main Class field, click and select Dictionary in the dialog that opens. IntelliJDEA creates the artifact configuration and shows its settings in the right-hand part of the ProjectStructure dialog.Apply the changes and close the dialog.Build the JAR artifactFrom the main menu, select Build | Build Artifacts.Point to Dictionary:jar and select Build.If you now look at the out/artifacts folder, you'll find your JAR thereRubrics