Question: In this project, you will use Hash table to store the shipments information for a shipping company. The program allows you to supplement the company

In this project, you will use Hash table to store the shipments information for a shipping company. The program allows you to supplement the company with additional new shipments. The shipment information includes the following:

String ShippingAddress // in this form: area_block_street_house String CustomerName int customerNumber int shipmentNumber

where the area is the key of the hash table. You need to write and submit a java program that includes three classes:

Shipment.java, ShippingService.java and ShippingTest.java. 1) Class Shipment

Instance variables:

private String shippingAddress; private String customerName; private int customerNo; private int shipmentNo ;

Methods:

  • A constructor that initializes the instance variables.

  • Set and get methods for each instance variable.

  • toString method that returns a string containing shippingAddress,

    customerName, customerNo and shipmentNo.

2) Class ShippingService

Instance variables:

private Shipment table[]; private int size;

// Hash table // Hash table size

CpE 207L: Data Structures Lab

Fall 2020/2021

Methods:

  • public ShippingService(int size)

    Create an array of shipments and save the size of the hash table.

  • public int hashFun(String address) Split the string address, based on underscore, to get the area. Then, find

    the summation of characters ASCII values of area and return the hash key.

  • public boolean insert(Shipment s)

    Insert the shipment s in the proper location and return true. When a collision happens, use linear or quadratic propping. If the hash table is full, return false.

  • public void printTable() Call toString() method and print the contents of the Hash Table as shown in

    the sample output.

  • public int countArea(String area) Count and return the number of shipments in the given area.

  • public void printCustomers(String area) Print all customers names in the given area.

    3) Class ShippingTest

    In the main method, create an object of class ShippingService with size = 13. 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. Add comments before each method.

    Sample output:

    Choose: 1. Insert shipments 2. Print all shipments 3. Count the shipments in a specific area 4. Print the customers names in a specific area 5. Exit 1 Insert the shipping address, customer name, customer number and shipment number. To stop, enter Q Kaifan_1_1_10

CpE 207L: Data Structures Lab Fall 2020/2021

Ahmad 11111111 905 Kaifan_3_3_13 Fatma 33333333 

305 Khaldiya_2_2_20 Aisha 22222222 820 Hawali_5_5_15 Ali 55555555 450 Salmiya_7_7_17 Sara 77777777 750 Q Choose: 1. Insert shipments 2. Print all shipments 3. Count the shipments 4. Print the customers 5. Exit 2 Shipping Address Customer Name

Salmiya_7_7_17 Kaifan_1_1_10 Kaifan_3_3_13 Khaldiya_2_2_20 Hawali_5_5_15 
Sara Ahmad Fatma Aisha Ali 

in a specific area names in a specific area

 Customer Number 77777777 
 11111111 33333333 22222222 55555555 

Choose: 1. Insert shipments 2. Print all shipments 3. Count the shipments 4. Print the customers 5. Exit 3 Enter the area: Kaifan The number of shipments in Kaifan = 2 Choose: 1. Insert shipments 2. Print all shipments 3. Count the shipments in a specific area

Shipment number 750 
 905 305 820 450 
in a specific area names in a specific area 

CpE 207L: Data Structures Lab

Fall 2020/2021

4. Print the customers names in a specific area 5. Exit 3 Enter the area:

hawali

The number of shipments in hawali = 1 Choose: 1. Insert shipments 2. Print all shipments

3. Count the shipments in a specific area 
4. Print the customers 5. Exit 4 Enter the area: kaifan 
Ahmad Fatma Choose: 1. Insert shipments 2. Print all shipments 3. Count the shipments 4. Print the customers 5. Exit 

4

Enter the area: 

Khaldiya

Aisha Choose: 1. Insert shipments 2. Print all shipments 3. Count the shipments 4. Print the customers 5. Exit 5 

names in a specific area

in a specific area names in a specific area

in a specific area names in a specific area

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!