/Users/johnr/Desktop/IA Submissions/IA Final Submission 000307-0023 - Jimmy/Product/ProductDataBase/src/ProductDataBase/SortandSearchClass.java |
1
2
3
4
5
6 package ProductDataBase;
7
8
9
10 @author
11
12 public class SortandSearchClass
13 {
14
15
16 public void selectionSortOfProductModel(Product[] productArray, int Productcounter)
17 {
18 for (int min = 0; min < Productcounter; min++)
19 {
20 int minIndex = min;
21 for (int j = min + 1; j < Productcounter; j++)
22 {
23 if (productArray[j].getModelNumber() < productArray[minIndex].getModelNumber())
24 {
25 minIndex = j;
26 }
27
28 if (minIndex != min)
29 {
30
31
32 Product temp = productArray[min];
33 productArray[min] = productArray[minIndex];
34 productArray[minIndex] = (temp);
35 }
36 }
37 }
38 }
39
40 public void selectionSortOfPurchaseOrderByOrderNumber(PurchaseOrder[] purchaseOrderArray, int Ordercounter)
41 {
42 for (int min = 0; min < Ordercounter; min++)
43 {
44 int minIndex = min;
45 for (int j = min + 1; j < Ordercounter; j++)
46 {
47 if (purchaseOrderArray[j].getPurchaseOrderNumber() < purchaseOrderArray[minIndex].getPurchaseOrderNumber())
48 {
49 minIndex = j;
50 }
51
52 if (minIndex != min)
53 {
54
55
56 PurchaseOrder temp = purchaseOrderArray[min];
57 purchaseOrderArray[min] = purchaseOrderArray[minIndex];
58 purchaseOrderArray[minIndex] = (temp);
59 }
60 }
61 }
62 }
63
64 public void selectionSortOfPurchaseOrderByModelNumber(PurchaseOrder[] purchaseOrderArray, int Ordercounter)
65 {
66 for (int min = 0; min < Ordercounter; min++)
67 {
68 int minIndex = min;
69 for (int j = min + 1; j < Ordercounter; j++)
70 {
71 if (purchaseOrderArray[j].getModelNumber() < purchaseOrderArray[minIndex].getModelNumber())
72 {
73 minIndex = j;
74 }
75
76 if (minIndex != min)
77 {
78
79
80 PurchaseOrder temp = purchaseOrderArray[min];
81 purchaseOrderArray[min] = purchaseOrderArray[minIndex];
82 purchaseOrderArray[minIndex] = (temp);
83 }
84 }
85 }
86 }
87
88 public void selectionSortOfPurchaseOrderByOrderID(PurchaseOrder[] purchaseOrderArray, int Ordercounter)
89 {
90 for (int min = 0; min < Ordercounter; min++)
91 {
92 int minIndex = min;
93 for (int j = min + 1; j < Ordercounter; j++)
94 {
95 if (purchaseOrderArray[j].getPurchaseOrderID() < purchaseOrderArray[minIndex].getPurchaseOrderID())
96 {
97 minIndex = j;
98 }
99
100 if (minIndex != min)
101 {
102
103
104 PurchaseOrder temp = purchaseOrderArray[min];
105 purchaseOrderArray[min] = purchaseOrderArray[minIndex];
106 purchaseOrderArray[minIndex] = (temp);
107 }
108 }
109 }
110 }
111 }
112