QuestionQuestion

Store Checkout System
For this assignment, you will create a portion of a retail store checkout system. This part of the system provides fast item lookup. A clerk (or customer) inputs a product stock number and the system returns the record for that item. The system is designed to provide facilities to add, remove and look up items, along with certain other utility functions. Your project will use the DictionaryADT interface to support your application program. The dictionary takes key=value pairs. Each key must be distinct; no duplicates are allowed. There may be duplicate values.

The Project:
This program consists of the ProductLookup application program, which allows the user to interact with the dictionary. You will implement theDictionaryADT iterface in three ways:
• A Hashtable
• A BinarySearchTree
• A Red/Black Tree
Your project will consist of the following files:
• ProductLookup.java    The application program (methods below).
• StockItem.java    The items that are stored in the dictionary.
• DictionaryADT.java    The Dictionary interface. (Provided)
• Hashtable.java    A hash table implementation of the DictionaryADT interface. Using chaining.
• UnorderedListADT.java   The List ADT interface (provided).
• LinkedList.java   Your linked list from program
• BinarySearchTree.java    The BST implementation of the DictionaryADT.
• BalancedTree.java   A red/black tree implementation of the DictionaryADT, which uses the Java API class java.util.TreeMap.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

public class DictionaryTester {

    public static void main(String[] args) {
       new DictionaryTester();
    }

    public DictionaryTester() {
       try {
            int DICTIONARY_SIZE = 10000;
            String[] testArray = getRandomStrings(DICTIONARY_SIZE);
            long start, stop;
            DictionaryADT<String, Integer> dictionary;

            System.out.println("Testing with randomly ordered data...\n");

            //test the Hashtable first. Load the table, and then search
            System.out.println("***************Testing the Hashtable...");

            dictionary = new Hashtable<String, Integer>(DICTIONARY_SIZE);
            for (int i = 0; i < DICTIONARY_SIZE; i++) {
                dictionary.insert(testArray[i], new Integer(i));
            }

            System.out.println("Now performing " + (DICTIONARY_SIZE * 10)
                   + " searches.");
            start = System.currentTimeMillis();
            for (int i = 0; i < DICTIONARY_SIZE * 10; i++) {
                int index = ((int) (DICTIONARY_SIZE * Math.random()));
                Integer val = (Integer) dictionary.getValue(testArray[index]);
                if (val == null) {
                   throw new RuntimeException(
                            "ERROR, key " + testArray[index] + " was not found");
                }
                if (val.intValue() != index) {
                   throw new RuntimeException(
                            "ERROR, wrong value returned, expected " + index
                            + " but got " + val);
                }
            }
            stop = System.currentTimeMillis();
            System.out.println("TIME: " + (stop - start) + "\n");

            System.out.println("Reverse lookups...");
            System.out.println("Now performing " + (DICTIONARY_SIZE / 10)
                   + " searches.");
            start = System.currentTimeMillis();
            for (int i = 0; i < DICTIONARY_SIZE / 10; i++) {
                int index = ((int) (DICTIONARY_SIZE * Math.random()));
                String key = (String) dictionary.getKey(new Integer(index));
                if (key == null) {
                   throw new RuntimeException(
                            "ERROR, key " + testArray[index] + " was not found");
                }...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$78.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats