Lab 4
Get started now
## Overview For this assignment you will create an autocomplete application. You will implement four strategies for looking up words that begin with the specified prefix and compare the performance of each strategy. ## Resources * [2000words.txt](/taylor/files/2000words.txt) * [words.txt](/taylor/files/words.txt) * [Top thousand domains](/taylor/files/top-1k.csv) ## Assignment The autocomplete GUI must be driven by a user dictionary. As the user types, all words that start with the typed letters must be displayed in a scrollable list. The program must allow the user to select a dictionary file and select which strategy to employ. Whenever a new strategy is selected, the dictionary should be re-loaded. ### GUI Details The GUI must contain the following elements in the locations described: * Two menus: - **File** menu with one option to **Open** a dictionary file - **Strategy** menu with a radio menu to select between the different strategies. It must be obvious to the user what each option means. * A search bar near the top in which the user can type * The autocomplete results must be shown below the search bar * Somewhere in the GUI, you must report the total number of autocomplete matches found and the time taken to find them - These statistics should be updated after each key press - Times must be displayed in the GUI using the following guidelines with up to three digits to the right of the decimal: + If the duration is shorter than a microsecond, the duration should be displayed in units of nanoseconds + If the duration is longer than a microsecond and shorter than a millisecond, the duration should be displayed in units of microseconds + If the duration is longer than a millisecond and shorter than a second, the duration should be displayed in units of milliseconds + Otherwise the duration should be formated as: `Minutes:Seconds.Milliseconds`, e.g., `00:25.660` <figure>[![Sample GUI](lab4.png)](lab4.png)<figcaption>Figure 1: Sample GUI</figcaption></figure> ### Class Structure You must create a `AutoCompleter` interface with the following methods: * `initialize(String filename)` - loads the dictionary file * `allThatBeginWith(String prefix)` - returns a list of all prefix matches in the dictionary, a.k.a., all entries in the dictionary that begin with prefix * `getLastOperationTime()` - returns the number of nanoseconds required by the last call to `initialize()` or `allThatBeginsWith()` Please note that `initialize()` must be called prior to calling either of the other two methods in the interface. If either of the other methods are called prior to calling `initialize()`, they should throw an `IllegalStateException` with the message: "Must call initialize() prior to calling this method." ### Lookup Strategies Each strategy must implement the `AutoCompleter` interface. You must implement four strategies: 1. Stores the words in an `ArrayList` and uses index methods (e.g., `get()`) to navigate the list 2. Stores the words in a `LinkedList` and uses index methods (e.g., `get()`) to navigate the list 3. Stores the words in an `ArrayList` and uses the enhanced `for` loop to navigate the list 4. Stores the words in a `LinkedList` and uses the enhanced `for` loop to navigate the list ### Dictionary Files Your program must support loading both `.txt` and `.csv` files. A `.txt` file should contain a list of words (one per line). A `.csv` file should contain a pair of values on each line. When reading a `.csv` file, your program should, at a minimum, create a string for each line that begins with everything after the comma. For example, `3,google.com` should become `google.com`. Optionally, you can concatenate the first value at the end of the string like this: `google.com: 3` to indicate the rank of the domain. Your program must support using the following files: * [2000words.txt](/taylor/files/2000words.txt) &mdash; A list of two thousand words. * [words.txt](/taylor/files/words.txt) &mdash; A list of a bit over one hundred thousand words. * [Top thousand domains](/taylor/files/top-1k.csv) &mdash; A list of the top thousand domains as measured by [Cisco Umbrella](http://s3-us-west-1.amazonaws.com/umbrella-static/index.html). ### Benchmarking You must provide benchmarking results for the four strategies when the user loads the [words.txt](/taylor/files/words.txt) file and types <kbd>f</kbd> in the search box. Also, you must provide benchmarking results for the four strategies when the user loads the [top-1k.csv](/taylor/files/top-1k.csv) file and types <kbd>f</kbd> in the search box. ### Exception Handling There are a number of situations that could cause your program to throw an exception. For example, if the file is not found, cannot be opened, or contains no data, it is likely that an exception will be thrown. In these cases, the program should display a meaningful message. ## Lab Deliverables > See your professor's instructions for details on submission guidelines and due dates. > * Dr. Taylor's students: See below > * All other students should refer to Blackboard > >If you have any questions, consult your instructor. ## Acknowledgements This assignment was written by [Dr. Josiah Yoder](https://faculty-web.msoe.edu/yoder) and [Dr. Chris Taylor](/taylor).

Friday, 22-Mar-2019 07:38:30 EDT