Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java method In this project, you are asked to use Hash Table to store Product information for a Store. The program allows you to supplement

java method
image text in transcribed
image text in transcribed
image text in transcribed
In this project, you are asked to use Hash Table to store Product information for a Store. The program allows you to supplement the Store with additional new Products. The Product information includes the following: String supplierAddress // in this form: area_block_street_building_phone int id 1/product id consists of 4 digits String product Name double price You need to write and submit a java program that includes three classes: Product.java, Store.java and Test.java. 1) Class Product Instance variables: private String supplier Address: private int id; private String productName; private double price; Methods: A constructor that initializes the instance variables. Set and get methods for each instance variable. toString method that returns a string containing supplierAddress, id, product Name and price. 2) Class Store Instance variables: private Product table(); private int size: // Hash table // Hash table size Methods: public Store(int size) Create an array of Products and save the size of the hash table. public int hashFun(String supplier Address, int id) Split the supplier Address string, based on underscore. Then, find the hash value according to the following steps: 1. Take the first character of the area, block, street, building and phone 2. Convert them to ASCII. 3. Cast them into int. 4. Add each value with power of 3 (3^0,3-1,3-2, 343) accordingly. 5. Add the result to the product id. 6. Finally return (result) % table size to get the hash value. public boolean insert(Product p) Insert the product p in the proper location and return true. When a collision happens, use quadratic propping. If the hash table is full, return false. Note: duplication is not allowed. public void printTable() Call toString method and print the contents of the Hash Table in a readable way. public int suppliers Count and return number of suppliers that deal with the store. public void maxPrices() print the product with the maximum price for each supplier. public boolean deletProduct(String supplierAddress, int id) Search the hash function and delete product the has the given attributes (supplierAddress, id). 3) Class Test In the main method, create an object of class Store with size 11. Display a menu of choices, as shown in the sample output. Add your sample output as a comment at the end of the test class. Sample output: 1. Insert product 2. delete product 3. Print all products 4. Count the number of suppliers, 5. Print product with max price per each supplier 6. Exit

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

LO2 Discuss important legal areas regarding safety and health.

Answered: 1 week ago