-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransactionList.java
More file actions
42 lines (37 loc) · 1002 Bytes
/
TransactionList.java
File metadata and controls
42 lines (37 loc) · 1002 Bytes
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
import java.util.*;
public class TransactionList extends ParentList {
private static final long serialVersionUID = 1L;
private static TransactionList trList;
public static TransactionList instance() {
if (trList == null)
return (trList = new TransactionList());
else
return trList;
}
/// returns a list of transactions that have the specified client ID
public LinkedList<Transaction> filterListByClient(int cID) {
LinkedList<Transaction> cLL = new LinkedList<Transaction>();
Iterator<Thing> iter = trList.getList();
Transaction t;
while (iter.hasNext()) {
t = (Transaction) iter.next();
if (t.getClientID() == cID) {
cLL.add(t);
}
}
return cLL;
}
/// returns the transaction if found
/// returns null if not found
public Transaction searchTransaction(int tID) {
Iterator<Thing> iter = trList.getList();
Transaction t;
while (iter.hasNext()) {
t = (Transaction) iter.next();
if (t.getID() == tID) {
return t;
}
}
return null;
}
}