HardwareStore Sort and Search Comparable Objects Program
Description
This program uses the selection sort, quick sort, and sequential search algorithms to conduct sorting and searching on an array of Comparable Inventory objects.Associated Concepts:
Comparable objects
Selection Sort, Quick Sort, and Sequential Search on an array of Comparable objects.
Selection Sort, Quick Sort, and Sequential Search on an array of Comparable objects.
Algorithm:
Inventory class:
Make objects of Inventory class as Comparable objects.
SortingSearchingComparbleObjects class:
In terms of algorithms, the method definitions of Selection Sort, Quick Sort, and Sequential Search are the same as the integer versions.
Since the objects in the array are Comparable objects, two objects can be compared directly using the object's compareTo() method.
Client main method:
Make objects of Inventory class as Comparable objects.
It implements Comparable interface.
Override compareTo() method.
Override compareTo() method.
SortingSearchingComparbleObjects class:
In terms of algorithms, the method definitions of Selection Sort, Quick Sort, and Sequential Search are the same as the integer versions.
Since the objects in the array are Comparable objects, two objects can be compared directly using the object's compareTo() method.
Client main method:
Call the methods defined in SortingSearchingComparbleObjects.java
to test them.