|
@@ -72,7 +72,7 @@ public class Checkbook {
|
72
|
72
|
return sum;
|
73
|
73
|
}
|
74
|
74
|
|
75
|
|
- public ArrayList<Transaction> getCheckbook() {
|
|
75
|
+ public List<Transaction> getCheckbook() {
|
76
|
76
|
return checkbook;
|
77
|
77
|
}
|
78
|
78
|
|
|
@@ -81,7 +81,7 @@ public class Checkbook {
|
81
|
81
|
List<Transaction> arr = new ArrayList<>();
|
82
|
82
|
for (Transaction ts : this.checkbook) {
|
83
|
83
|
Object valueToCheck = getObject(fieldName, ts);
|
84
|
|
- if (valueToCheck.equals(value)) {
|
|
84
|
+ if (valueToCheck != null && valueToCheck.equals(value)) {
|
85
|
85
|
arr.add(ts);
|
86
|
86
|
}
|
87
|
87
|
}
|
|
@@ -97,11 +97,9 @@ public class Checkbook {
|
97
|
97
|
} catch (NoSuchFieldException | IllegalAccessException noField) {
|
98
|
98
|
noField.printStackTrace();
|
99
|
99
|
}
|
100
|
|
-
|
101
|
100
|
return null;
|
102
|
101
|
}
|
103
|
102
|
|
104
|
|
-
|
105
|
103
|
public boolean containsAll(Collection<Transaction> c) {
|
106
|
104
|
return checkbook.containsAll(c);
|
107
|
105
|
}
|
|
@@ -118,22 +116,11 @@ public class Checkbook {
|
118
|
116
|
checkbook.clear();
|
119
|
117
|
}
|
120
|
118
|
|
121
|
|
- private Transaction[] getAllTransactionByType(TransactionType tt) {
|
122
|
|
- ArrayList<Transaction> arr = new ArrayList<>();
|
123
|
|
- for (Transaction t: this.checkbook) {
|
124
|
|
- if (t.getType().equals(tt)) {
|
125
|
|
- arr.add(t);
|
126
|
|
- }
|
127
|
|
- }
|
128
|
|
- return this.toArrayFromList(arr);
|
129
|
|
- }
|
130
|
|
-
|
131
|
|
-
|
132
|
119
|
public Transaction[] getAllDebitTransactions() {
|
133
|
|
- return getAllTransactionByType(TransactionType.DEBIT);
|
|
120
|
+ return getSpecificTransactions("typee", TransactionType.DEBIT);
|
134
|
121
|
}
|
135
|
122
|
|
136
|
123
|
public Transaction[] getAllCreditTransactions() {
|
137
|
|
- return getAllTransactionByType(TransactionType.CREDIT);
|
|
124
|
+ return getSpecificTransactions("typee", TransactionType.CREDIT);
|
138
|
125
|
}
|
139
|
126
|
}
|