NedRedmond 6 年之前
父節點
當前提交
479c372b8b
共有 2 個文件被更改,包括 119 次插入83 次删除
  1. 66
    83
      Checkbook/.idea/workspace.xml
  2. 53
    0
      Checkbook/src/main/java/Checkbook.java

+ 66
- 83
Checkbook/.idea/workspace.xml 查看文件

@@ -2,11 +2,8 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="86bea83e-ff28-4c08-8563-407f3ac4c927" name="Default Changelist" comment="">
5
-      <change beforePath="$PROJECT_DIR$/Checkbook.iml" beforeDir="false" />
6
-      <change beforePath="$PROJECT_DIR$/src/main/java/AccountBook.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/AccountBook.java" afterDir="false" />
5
+      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
7 6
       <change beforePath="$PROJECT_DIR$/src/main/java/Checkbook.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Checkbook.java" afterDir="false" />
8
-      <change beforePath="$PROJECT_DIR$/src/main/java/Transaction.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Transaction.java" afterDir="false" />
9
-      <change beforePath="$PROJECT_DIR$/src/test/java/CheckbookTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/CheckbookTest.java" afterDir="false" />
10 7
     </list>
11 8
     <ignored path="$PROJECT_DIR$/target/" />
12 9
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -16,7 +13,7 @@
16 13
     <option name="LAST_RESOLUTION" value="IGNORE" />
17 14
   </component>
18 15
   <component name="FileEditorManager">
19
-    <leaf>
16
+    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
20 17
       <file pinned="false" current-in-tab="false">
21 18
         <entry file="file://$PROJECT_DIR$/src/main/java/AccountBook.java">
22 19
           <provider selected="true" editor-type-id="text-editor">
@@ -29,27 +26,19 @@
29 26
       <file pinned="false" current-in-tab="true">
30 27
         <entry file="file://$PROJECT_DIR$/src/main/java/Checkbook.java">
31 28
           <provider selected="true" editor-type-id="text-editor">
32
-            <state relative-caret-position="1311">
33
-              <caret line="57" column="5" selection-start-line="57" selection-start-column="5" selection-end-line="57" selection-end-column="5" />
29
+            <state relative-caret-position="386">
30
+              <caret line="136" column="57" selection-start-line="136" selection-start-column="57" selection-end-line="136" selection-end-column="57" />
34 31
               <folding>
35
-                <element signature="e#224#225#0" expanded="true" />
36
-                <element signature="e#276#277#0" expanded="true" />
37
-                <element signature="e#478#479#0" expanded="true" />
38
-                <element signature="e#502#503#0" expanded="true" />
39
-                <element signature="e#548#549#0" expanded="true" />
40
-                <element signature="e#576#577#0" expanded="true" />
41
-                <element signature="e#723#724#0" expanded="true" />
42
-                <element signature="e#751#752#0" expanded="true" />
43
-                <element signature="e#821#822#0" expanded="true" />
44
-                <element signature="e#866#867#0" expanded="true" />
45
-                <element signature="e#799#800#0" expanded="true" />
46
-                <element signature="e#840#841#0" expanded="true" />
47
-                <element signature="e#1045#1046#0" expanded="true" />
48
-                <element signature="e#1069#1070#0" expanded="true" />
32
+                <element signature="imports" expanded="true" />
33
+                <element signature="e#1440#1441#0" expanded="true" />
49 34
                 <element signature="e#1485#1486#0" expanded="true" />
35
+                <element signature="e#1550#1551#0" expanded="true" />
50 36
                 <element signature="e#1600#1601#0" expanded="true" />
37
+                <element signature="e#1935#1936#0" expanded="true" />
51 38
                 <element signature="e#1983#1984#0" expanded="true" />
39
+                <element signature="e#2046#2047#0" expanded="true" />
52 40
                 <element signature="e#2094#2095#0" expanded="true" />
41
+                <element signature="e#2135#2136#0" expanded="true" />
53 42
                 <element signature="e#2171#2172#0" expanded="true" />
54 43
               </folding>
55 44
             </state>
@@ -59,7 +48,7 @@
59 48
       <file pinned="false" current-in-tab="false">
60 49
         <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/src.zip!/java/util/ArrayList.java">
61 50
           <provider selected="true" editor-type-id="text-editor">
62
-            <state relative-caret-position="-945">
51
+            <state relative-caret-position="15203">
63 52
               <caret line="701" column="59" selection-start-line="701" selection-start-column="53" selection-end-line="701" selection-end-column="59" />
64 53
             </state>
65 54
           </provider>
@@ -69,7 +58,7 @@
69 58
         <entry file="file://$PROJECT_DIR$/src/main/java/GenericAccount.java">
70 59
           <provider selected="true" editor-type-id="text-editor">
71 60
             <state relative-caret-position="23">
72
-              <caret line="1" column="13" selection-start-line="1" selection-start-column="13" selection-end-line="1" selection-end-column="13" />
61
+              <caret line="1" column="52" selection-start-line="1" selection-start-column="52" selection-end-line="1" selection-end-column="52" />
73 62
             </state>
74 63
           </provider>
75 64
         </entry>
@@ -77,7 +66,7 @@
77 66
       <file pinned="false" current-in-tab="false">
78 67
         <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/src.zip!/java/util/Collection.java">
79 68
           <provider selected="true" editor-type-id="text-editor">
80
-            <state relative-caret-position="187">
69
+            <state relative-caret-position="2714">
81 70
               <caret line="143" column="17" selection-start-line="143" selection-start-column="17" selection-end-line="143" selection-end-column="17" />
82 71
             </state>
83 72
           </provider>
@@ -109,12 +98,13 @@
109 98
         <option value="$PROJECT_DIR$/src/main/java/Transaction.java" />
110 99
         <option value="$PROJECT_DIR$/src/main/java/AccountBook.java" />
111 100
         <option value="$PROJECT_DIR$/src/test/java/CheckbookTest.java" />
101
+        <option value="$PROJECT_DIR$/src/main/java/GenericAccount.java" />
112 102
         <option value="$PROJECT_DIR$/src/main/java/Checkbook.java" />
113 103
       </list>
114 104
     </option>
115 105
   </component>
116
-  <component name="ProjectFrameBounds" extendedState="6" fullScreen="true">
117
-    <option name="width" value="1440" />
106
+  <component name="ProjectFrameBounds" fullScreen="true">
107
+    <option name="width" value="584" />
118 108
     <option name="height" value="900" />
119 109
   </component>
120 110
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
@@ -123,7 +113,6 @@
123 113
       <foldersAlwaysOnTop value="true" />
124 114
     </navigator>
125 115
     <panes>
126
-      <pane id="PackagesPane" />
127 116
       <pane id="Scope" />
128 117
       <pane id="ProjectPane">
129 118
         <subPane>
@@ -167,12 +156,13 @@
167 156
           <select />
168 157
         </subPane>
169 158
       </pane>
159
+      <pane id="PackagesPane" />
170 160
     </panes>
171 161
   </component>
172 162
   <component name="PropertiesComponent">
173 163
     <property name="WebServerToolWindowFactoryState" value="false" />
174 164
     <property name="aspect.path.notification.shown" value="true" />
175
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544213381725" />
165
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544229309062" />
176 166
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
177 167
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrarySuperClass.JUnit4" value="" />
178 168
     <property name="extract.method.default.visibility" value="private" />
@@ -209,30 +199,26 @@
209 199
       <option name="number" value="Default" />
210 200
       <option name="presentableId" value="Default" />
211 201
       <updated>1544199126934</updated>
212
-      <workItem from="1544199128297" duration="10136000" />
202
+      <workItem from="1544199128297" duration="10411000" />
203
+      <workItem from="1544228672333" duration="635000" />
213 204
     </task>
214 205
     <servers />
215 206
   </component>
216 207
   <component name="TimeTrackingManager">
217
-    <option name="totallyTimeSpent" value="10136000" />
208
+    <option name="totallyTimeSpent" value="11046000" />
218 209
   </component>
219 210
   <component name="ToolWindowManager">
220
-    <frame x="0" y="0" width="904" height="900" extended-state="6" />
211
+    <frame x="0" y="0" width="1440" height="900" extended-state="6" />
221 212
     <editor active="true" />
222 213
     <layout>
223
-      <window_info id="Favorites" side_tool="true" />
224
-      <window_info id="Image Layers" />
225
-      <window_info id="Designer" />
226
-      <window_info id="UI Designer" />
227
-      <window_info id="Capture Tool" />
228
-      <window_info id="Learn" />
229
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.26218098" />
214
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.42274678" />
230 215
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
231
-      <window_info anchor="bottom" id="Docker" show_stripe_button="false" />
232
-      <window_info anchor="bottom" id="Version Control" />
233
-      <window_info anchor="bottom" id="Terminal" />
234
-      <window_info anchor="bottom" id="Event Log" side_tool="true" />
235
-      <window_info anchor="bottom" id="Database Changes" />
216
+      <window_info id="Designer" order="2" />
217
+      <window_info id="Image Layers" order="3" />
218
+      <window_info id="Capture Tool" order="4" />
219
+      <window_info id="UI Designer" order="5" />
220
+      <window_info id="Learn" order="6" />
221
+      <window_info id="Favorites" order="7" side_tool="true" />
236 222
       <window_info anchor="bottom" id="Message" order="0" />
237 223
       <window_info anchor="bottom" id="Find" order="1" />
238 224
       <window_info anchor="bottom" id="Run" order="2" />
@@ -240,35 +226,26 @@
240 226
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
241 227
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
242 228
       <window_info anchor="bottom" id="TODO" order="6" />
243
-      <window_info anchor="right" id="Palette" />
244
-      <window_info anchor="right" id="Theme Preview" />
245
-      <window_info anchor="right" id="Maven" />
246
-      <window_info anchor="right" id="Capture Analysis" />
247
-      <window_info anchor="right" id="Palette&#9;" />
248
-      <window_info anchor="right" id="Database" />
229
+      <window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
230
+      <window_info anchor="bottom" id="Version Control" order="8" />
231
+      <window_info anchor="bottom" id="Database Changes" order="9" />
232
+      <window_info anchor="bottom" id="Terminal" order="10" />
233
+      <window_info anchor="bottom" id="Event Log" order="11" side_tool="true" />
249 234
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
250 235
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
251 236
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
237
+      <window_info anchor="right" id="Palette" order="3" />
238
+      <window_info anchor="right" id="Theme Preview" order="4" />
239
+      <window_info anchor="right" id="Maven" order="5" />
240
+      <window_info anchor="right" id="Capture Analysis" order="6" />
241
+      <window_info anchor="right" id="Palette&#9;" order="7" />
242
+      <window_info anchor="right" id="Database" order="8" />
252 243
     </layout>
253 244
   </component>
254 245
   <component name="TypeScriptGeneratedFilesManager">
255 246
     <option name="version" value="1" />
256 247
   </component>
257 248
   <component name="editorHistoryManager">
258
-    <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/src.zip!/java/util/Collection.java">
259
-      <provider selected="true" editor-type-id="text-editor">
260
-        <state relative-caret-position="187">
261
-          <caret line="143" column="17" selection-start-line="143" selection-start-column="17" selection-end-line="143" selection-end-column="17" />
262
-        </state>
263
-      </provider>
264
-    </entry>
265
-    <entry file="file://$PROJECT_DIR$/src/main/java/AccountBook.java">
266
-      <provider selected="true" editor-type-id="text-editor">
267
-        <state relative-caret-position="46">
268
-          <caret line="2" column="10" selection-start-line="2" selection-start-column="10" selection-end-line="2" selection-end-column="10" />
269
-        </state>
270
-      </provider>
271
-    </entry>
272 249
     <entry file="file://$PROJECT_DIR$/src/main/java/Transaction.java">
273 250
       <provider selected="true" editor-type-id="text-editor">
274 251
         <state relative-caret-position="299">
@@ -297,43 +274,49 @@
297 274
         </state>
298 275
       </provider>
299 276
     </entry>
300
-    <entry file="file://$PROJECT_DIR$/src/main/java/GenericAccount.java">
277
+    <entry file="file://$PROJECT_DIR$/src/main/java/AccountBook.java">
301 278
       <provider selected="true" editor-type-id="text-editor">
302
-        <state relative-caret-position="23">
303
-          <caret line="1" column="13" selection-start-line="1" selection-start-column="13" selection-end-line="1" selection-end-column="13" />
279
+        <state relative-caret-position="46">
280
+          <caret line="2" column="10" selection-start-line="2" selection-start-column="10" selection-end-line="2" selection-end-column="10" />
304 281
         </state>
305 282
       </provider>
306 283
     </entry>
307 284
     <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/src.zip!/java/util/ArrayList.java">
308 285
       <provider selected="true" editor-type-id="text-editor">
309
-        <state relative-caret-position="-945">
286
+        <state relative-caret-position="15203">
310 287
           <caret line="701" column="59" selection-start-line="701" selection-start-column="53" selection-end-line="701" selection-end-column="59" />
311 288
         </state>
312 289
       </provider>
313 290
     </entry>
291
+    <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/src.zip!/java/util/Collection.java">
292
+      <provider selected="true" editor-type-id="text-editor">
293
+        <state relative-caret-position="2714">
294
+          <caret line="143" column="17" selection-start-line="143" selection-start-column="17" selection-end-line="143" selection-end-column="17" />
295
+        </state>
296
+      </provider>
297
+    </entry>
298
+    <entry file="file://$PROJECT_DIR$/src/main/java/GenericAccount.java">
299
+      <provider selected="true" editor-type-id="text-editor">
300
+        <state relative-caret-position="23">
301
+          <caret line="1" column="52" selection-start-line="1" selection-start-column="52" selection-end-line="1" selection-end-column="52" />
302
+        </state>
303
+      </provider>
304
+    </entry>
314 305
     <entry file="file://$PROJECT_DIR$/src/main/java/Checkbook.java">
315 306
       <provider selected="true" editor-type-id="text-editor">
316
-        <state relative-caret-position="1311">
317
-          <caret line="57" column="5" selection-start-line="57" selection-start-column="5" selection-end-line="57" selection-end-column="5" />
307
+        <state relative-caret-position="386">
308
+          <caret line="136" column="57" selection-start-line="136" selection-start-column="57" selection-end-line="136" selection-end-column="57" />
318 309
           <folding>
319
-            <element signature="e#224#225#0" expanded="true" />
320
-            <element signature="e#276#277#0" expanded="true" />
321
-            <element signature="e#478#479#0" expanded="true" />
322
-            <element signature="e#502#503#0" expanded="true" />
323
-            <element signature="e#548#549#0" expanded="true" />
324
-            <element signature="e#576#577#0" expanded="true" />
325
-            <element signature="e#723#724#0" expanded="true" />
326
-            <element signature="e#751#752#0" expanded="true" />
327
-            <element signature="e#821#822#0" expanded="true" />
328
-            <element signature="e#866#867#0" expanded="true" />
329
-            <element signature="e#799#800#0" expanded="true" />
330
-            <element signature="e#840#841#0" expanded="true" />
331
-            <element signature="e#1045#1046#0" expanded="true" />
332
-            <element signature="e#1069#1070#0" expanded="true" />
310
+            <element signature="imports" expanded="true" />
311
+            <element signature="e#1440#1441#0" expanded="true" />
333 312
             <element signature="e#1485#1486#0" expanded="true" />
313
+            <element signature="e#1550#1551#0" expanded="true" />
334 314
             <element signature="e#1600#1601#0" expanded="true" />
315
+            <element signature="e#1935#1936#0" expanded="true" />
335 316
             <element signature="e#1983#1984#0" expanded="true" />
317
+            <element signature="e#2046#2047#0" expanded="true" />
336 318
             <element signature="e#2094#2095#0" expanded="true" />
319
+            <element signature="e#2135#2136#0" expanded="true" />
337 320
             <element signature="e#2171#2172#0" expanded="true" />
338 321
           </folding>
339 322
         </state>

+ 53
- 0
Checkbook/src/main/java/Checkbook.java 查看文件

@@ -1,3 +1,4 @@
1
+import java.time.LocalDate;
1 2
 import java.util.*;
2 3
 
3 4
 public class Checkbook<T extends Transaction> implements Collection<T> {
@@ -88,6 +89,58 @@ public class Checkbook<T extends Transaction> implements Collection<T> {
88 89
         transactions.clear();
89 90
     }
90 91
 
92
+    public double checkbookValue(){
93
+        double sum = 0.0;
94
+        for (Transaction t : transactions) {
95
+            if (t.getType().equals(TransactionType.CREDIT)) {
96
+                sum += t.getAmount();
97
+            } else {
98
+                sum -= t.getAmount();
99
+            }
100
+        }
101
+        return sum;
102
+    }
103
+
104
+    public Transaction[] getTransactionsForDate(LocalDate aDate) {
105
+        ArrayList<Transaction> dateList = new ArrayList<>();
106
+        for (Transaction t : transactions) {
107
+            if (t.getDate().equals(aDate)) {
108
+                dateList.add(t);
109
+            }
110
+        }
111
+        return dateList.toArray(new Transaction[0]);
112
+    }
113
+
114
+    Transaction[] getAllTransactionsForPayee(Payee payee) {
115
+        ArrayList<Transaction> payeeList = new ArrayList<>();
116
+        for (Transaction t : transactions) {
117
+            if (t.getPayee().equals(payee)) {
118
+                payeeList.add(t);
119
+            }
120
+        }
121
+        return payeeList.toArray(new Transaction[0]);
122
+    }
123
+
124
+    Transaction[] getAllDebitTransactions() {
125
+        ArrayList<Transaction> debitList = new ArrayList<>();
126
+        for (Transaction t : transactions) {
127
+            if (t.getType().equals(TransactionType.DEBIT)) {
128
+                debitList.add(t);
129
+            }
130
+        }
131
+        return debitList.toArray(new Transaction[0]);
132
+    }
133
+
134
+    Transaction[] getAllCreditTransactions() {
135
+        ArrayList<Transaction> creditList = new ArrayList<>();
136
+        for (Transaction t : transactions) {
137
+            if (t.getType().equals(TransactionType.CREDIT)) {
138
+                creditList.add(t);
139
+            }
140
+        }
141
+        return creditList.toArray(new Transaction[0]);
142
+    }
143
+
91 144
     //blind us with your Java eloquence....
92 145
 
93 146
 }