-
Notifications
You must be signed in to change notification settings - Fork 1
/
SupplierList.java
50 lines (40 loc) · 1.05 KB
/
SupplierList.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.util.*;
import java.io.*;
public class SupplierList implements Serializable {
private static final long serialVersionUID = 1L;
private List<Supplier> suppliers = new LinkedList<Supplier>();
private static SupplierList SupplierList;
private SupplierList() { }
public static SupplierList instance() {
if (SupplierList == null) {
return (SupplierList = new SupplierList());
} else {
return SupplierList;
}
}
public Iterator<Supplier> getSuppliers() {
return suppliers.iterator();
}
public boolean insertSupplier(Supplier supplier) {
return suppliers.add(supplier);
}
public Supplier searchSupplier(String supplierID)
{
Iterator supplierIterator = suppliers.iterator();
while (supplierIterator.hasNext())
{
Supplier supplier = (Supplier)(supplierIterator.next());
if (supplier.getSupplierID().equals(supplierID))
{
return supplier;
}
}
return null;
}
// public Iterator getSupplierList(){
// return suppliers.iterator();
// }
public String toString() {
return suppliers.toString();
}
}