Vincent Sima 8 лет назад
Родитель
Сommit
d522903509

Двоичные данные
.DS_Store Просмотреть файл


+ 8
- 1
pom.xml Просмотреть файл

@@ -8,5 +8,12 @@
8 8
     <artifactId>payment</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10 10
 
11
-
11
+    <dependencies>
12
+        <dependency>
13
+            <groupId>org.junit.jupiter</groupId>
14
+            <artifactId>junit-jupiter-api</artifactId>
15
+            <version>5.2.0</version>
16
+            <scope>test</scope>
17
+        </dependency>
18
+    </dependencies>
12 19
 </project>

Двоичные данные
src/.DS_Store Просмотреть файл


+ 7
- 0
src/.idea/misc.xml Просмотреть файл

@@ -0,0 +1,7 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="JavaScriptSettings">
4
+    <option name="languageLevel" value="ES6" />
5
+  </component>
6
+  <component name="ProjectRootManager" version="2" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
7
+</project>

+ 8
- 0
src/.idea/modules.xml Просмотреть файл

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectModuleManager">
4
+    <modules>
5
+      <module fileurl="file://$PROJECT_DIR$/.idea/src.iml" filepath="$PROJECT_DIR$/.idea/src.iml" />
6
+    </modules>
7
+  </component>
8
+</project>

+ 327
- 0
src/.idea/workspace.xml Просмотреть файл

@@ -0,0 +1,327 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ChangeListManager">
4
+    <list default="true" id="61162ab7-5df2-4423-a4ed-3b7e173ee5e7" name="Default" comment="" />
5
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
6
+    <option name="TRACKING_ENABLED" value="true" />
7
+    <option name="SHOW_DIALOG" value="false" />
8
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
9
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
10
+    <option name="LAST_RESOLUTION" value="IGNORE" />
11
+  </component>
12
+  <component name="FileEditorManager">
13
+    <leaf>
14
+      <file leaf-file-name="Payment.java" pinned="false" current-in-tab="false">
15
+        <entry file="file://$PROJECT_DIR$/main/java/com/zipcoder/payment/Payment.java">
16
+          <provider selected="true" editor-type-id="text-editor" />
17
+        </entry>
18
+      </file>
19
+      <file leaf-file-name="Check.java" pinned="false" current-in-tab="false">
20
+        <entry file="file://$PROJECT_DIR$/main/java/com/zipcoder/payment/Check.java">
21
+          <provider selected="true" editor-type-id="text-editor">
22
+            <state relative-caret-position="279">
23
+              <caret line="21" lean-forward="true" selection-start-line="21" selection-end-line="21" />
24
+            </state>
25
+          </provider>
26
+        </entry>
27
+      </file>
28
+      <file leaf-file-name="CreditCard.java" pinned="false" current-in-tab="false">
29
+        <entry file="file://$PROJECT_DIR$/main/java/com/zipcoder/payment/CreditCard.java">
30
+          <provider selected="true" editor-type-id="text-editor" />
31
+        </entry>
32
+      </file>
33
+      <file leaf-file-name="PayPal.java" pinned="false" current-in-tab="false">
34
+        <entry file="file://$PROJECT_DIR$/main/java/com/zipcoder/payment/PayPal.java">
35
+          <provider selected="true" editor-type-id="text-editor">
36
+            <state relative-caret-position="-10" />
37
+          </provider>
38
+        </entry>
39
+      </file>
40
+      <file leaf-file-name="PayPalTest.java" pinned="false" current-in-tab="true">
41
+        <entry file="file://$PROJECT_DIR$/test/java/com/zipcoder/payment/PayPalTest.java">
42
+          <provider selected="true" editor-type-id="text-editor">
43
+            <state relative-caret-position="402">
44
+              <caret line="64" column="2" lean-forward="true" selection-start-line="64" selection-start-column="2" selection-end-line="64" selection-end-column="2" />
45
+            </state>
46
+          </provider>
47
+        </entry>
48
+      </file>
49
+    </leaf>
50
+  </component>
51
+  <component name="IdeDocumentHistory">
52
+    <option name="CHANGED_PATHS">
53
+      <list>
54
+        <option value="$PROJECT_DIR$/test/java/com/zipcoder/payment/PayPalTest.java" />
55
+      </list>
56
+    </option>
57
+  </component>
58
+  <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
59
+  <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
60
+  <component name="JsGulpfileManager">
61
+    <detection-done>true</detection-done>
62
+    <sorting>DEFINITION_ORDER</sorting>
63
+  </component>
64
+  <component name="NodePackageJsonFileManager">
65
+    <packageJsonPaths />
66
+  </component>
67
+  <component name="ProjectFrameBounds">
68
+    <option name="y" value="23" />
69
+    <option name="width" value="1280" />
70
+    <option name="height" value="705" />
71
+  </component>
72
+  <component name="ProjectView">
73
+    <navigator proportions="" version="1">
74
+      <foldersAlwaysOnTop value="true" />
75
+    </navigator>
76
+    <panes>
77
+      <pane id="Scope" />
78
+      <pane id="PackagesPane" />
79
+      <pane id="AndroidView" />
80
+      <pane id="ProjectPane">
81
+        <subPane>
82
+          <expand>
83
+            <path>
84
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
85
+              <item name="src" type="462c0819:PsiDirectoryNode" />
86
+            </path>
87
+            <path>
88
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
89
+              <item name="src" type="462c0819:PsiDirectoryNode" />
90
+              <item name="main" type="462c0819:PsiDirectoryNode" />
91
+            </path>
92
+            <path>
93
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
94
+              <item name="src" type="462c0819:PsiDirectoryNode" />
95
+              <item name="main" type="462c0819:PsiDirectoryNode" />
96
+              <item name="java" type="462c0819:PsiDirectoryNode" />
97
+            </path>
98
+            <path>
99
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
100
+              <item name="src" type="462c0819:PsiDirectoryNode" />
101
+              <item name="main" type="462c0819:PsiDirectoryNode" />
102
+              <item name="java" type="462c0819:PsiDirectoryNode" />
103
+              <item name="com" type="462c0819:PsiDirectoryNode" />
104
+            </path>
105
+            <path>
106
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
107
+              <item name="src" type="462c0819:PsiDirectoryNode" />
108
+              <item name="main" type="462c0819:PsiDirectoryNode" />
109
+              <item name="java" type="462c0819:PsiDirectoryNode" />
110
+              <item name="com" type="462c0819:PsiDirectoryNode" />
111
+              <item name="zipcoder" type="462c0819:PsiDirectoryNode" />
112
+            </path>
113
+            <path>
114
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
115
+              <item name="src" type="462c0819:PsiDirectoryNode" />
116
+              <item name="main" type="462c0819:PsiDirectoryNode" />
117
+              <item name="java" type="462c0819:PsiDirectoryNode" />
118
+              <item name="com" type="462c0819:PsiDirectoryNode" />
119
+              <item name="zipcoder" type="462c0819:PsiDirectoryNode" />
120
+              <item name="payment" type="462c0819:PsiDirectoryNode" />
121
+            </path>
122
+            <path>
123
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
124
+              <item name="src" type="462c0819:PsiDirectoryNode" />
125
+              <item name="test" type="462c0819:PsiDirectoryNode" />
126
+            </path>
127
+            <path>
128
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
129
+              <item name="src" type="462c0819:PsiDirectoryNode" />
130
+              <item name="test" type="462c0819:PsiDirectoryNode" />
131
+              <item name="java" type="462c0819:PsiDirectoryNode" />
132
+            </path>
133
+            <path>
134
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
135
+              <item name="src" type="462c0819:PsiDirectoryNode" />
136
+              <item name="test" type="462c0819:PsiDirectoryNode" />
137
+              <item name="java" type="462c0819:PsiDirectoryNode" />
138
+              <item name="com" type="462c0819:PsiDirectoryNode" />
139
+            </path>
140
+            <path>
141
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
142
+              <item name="src" type="462c0819:PsiDirectoryNode" />
143
+              <item name="test" type="462c0819:PsiDirectoryNode" />
144
+              <item name="java" type="462c0819:PsiDirectoryNode" />
145
+              <item name="com" type="462c0819:PsiDirectoryNode" />
146
+              <item name="zipcoder" type="462c0819:PsiDirectoryNode" />
147
+            </path>
148
+            <path>
149
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
150
+              <item name="src" type="462c0819:PsiDirectoryNode" />
151
+              <item name="test" type="462c0819:PsiDirectoryNode" />
152
+              <item name="java" type="462c0819:PsiDirectoryNode" />
153
+              <item name="com" type="462c0819:PsiDirectoryNode" />
154
+              <item name="zipcoder" type="462c0819:PsiDirectoryNode" />
155
+              <item name="payment" type="462c0819:PsiDirectoryNode" />
156
+            </path>
157
+          </expand>
158
+          <select />
159
+        </subPane>
160
+      </pane>
161
+    </panes>
162
+  </component>
163
+  <component name="PropertiesComponent">
164
+    <property name="WebServerToolWindowFactoryState" value="false" />
165
+    <property name="aspect.path.notification.shown" value="true" />
166
+    <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
167
+    <property name="nodejs_npm_path_reset_for_default_project" value="true" />
168
+  </component>
169
+  <component name="RunDashboard">
170
+    <option name="ruleStates">
171
+      <list>
172
+        <RuleState>
173
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
174
+        </RuleState>
175
+        <RuleState>
176
+          <option name="name" value="StatusDashboardGroupingRule" />
177
+        </RuleState>
178
+      </list>
179
+    </option>
180
+  </component>
181
+  <component name="RunManager">
182
+    <configuration default="true" type="Application" factoryName="Application">
183
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
184
+    </configuration>
185
+    <configuration default="true" type="JUnit" factoryName="JUnit">
186
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
187
+      <option name="ALTERNATIVE_JRE_PATH" />
188
+      <option name="PACKAGE_NAME" />
189
+      <option name="MAIN_CLASS_NAME" />
190
+      <option name="METHOD_NAME" />
191
+      <option name="TEST_OBJECT" value="class" />
192
+      <option name="VM_PARAMETERS" value="-ea" />
193
+      <option name="PARAMETERS" />
194
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
195
+      <option name="PASS_PARENT_ENVS" value="true" />
196
+      <option name="TEST_SEARCH_SCOPE">
197
+        <value defaultName="singleModule" />
198
+      </option>
199
+      <patterns />
200
+    </configuration>
201
+    <configuration default="true" type="TestNG" factoryName="TestNG">
202
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
203
+      <option name="ALTERNATIVE_JRE_PATH" />
204
+      <option name="SUITE_NAME" />
205
+      <option name="PACKAGE_NAME" />
206
+      <option name="MAIN_CLASS_NAME" />
207
+      <option name="METHOD_NAME" />
208
+      <option name="GROUP_NAME" />
209
+      <option name="TEST_OBJECT" value="CLASS" />
210
+      <option name="VM_PARAMETERS" value="-ea" />
211
+      <option name="PARAMETERS" />
212
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
213
+      <option name="OUTPUT_DIRECTORY" />
214
+      <option name="PASS_PARENT_ENVS" value="true" />
215
+      <option name="TEST_SEARCH_SCOPE">
216
+        <value defaultName="singleModule" />
217
+      </option>
218
+      <option name="USE_DEFAULT_REPORTERS" value="false" />
219
+      <option name="PROPERTIES_FILE" />
220
+      <properties />
221
+      <listeners />
222
+    </configuration>
223
+  </component>
224
+  <component name="SvnConfiguration">
225
+    <configuration />
226
+  </component>
227
+  <component name="TaskManager">
228
+    <task active="true" id="Default" summary="Default task">
229
+      <changelist id="61162ab7-5df2-4423-a4ed-3b7e173ee5e7" name="Default" comment="" />
230
+      <created>1528481188904</created>
231
+      <option name="number" value="Default" />
232
+      <option name="presentableId" value="Default" />
233
+      <updated>1528481188904</updated>
234
+      <workItem from="1528481193742" duration="57000" />
235
+      <workItem from="1528908426822" duration="648000" />
236
+    </task>
237
+    <servers />
238
+  </component>
239
+  <component name="TimeTrackingManager">
240
+    <option name="totallyTimeSpent" value="705000" />
241
+  </component>
242
+  <component name="ToolWindowManager">
243
+    <frame x="0" y="23" width="1280" height="705" extended-state="6" />
244
+    <editor active="true" />
245
+    <layout>
246
+      <window_info anchor="right" id="Palette" order="3" />
247
+      <window_info anchor="bottom" id="TODO" order="6" />
248
+      <window_info anchor="right" id="Palette&#9;" order="3" />
249
+      <window_info id="Image Layers" order="2" />
250
+      <window_info anchor="right" id="Capture Analysis" order="3" />
251
+      <window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
252
+      <window_info anchor="right" id="Maven Projects" order="3" />
253
+      <window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
254
+      <window_info anchor="bottom" id="Version Control" order="7" show_stripe_button="false" />
255
+      <window_info anchor="bottom" id="Run" order="2" />
256
+      <window_info anchor="bottom" id="Terminal" order="7" />
257
+      <window_info id="Capture Tool" order="2" />
258
+      <window_info id="Designer" order="2" />
259
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.2536349" />
260
+      <window_info anchor="right" id="Database" order="3" />
261
+      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
262
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
263
+      <window_info id="UI Designer" order="2" />
264
+      <window_info anchor="right" id="Theme Preview" order="3" />
265
+      <window_info id="Favorites" order="2" side_tool="true" />
266
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
267
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
268
+      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
269
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
270
+      <window_info anchor="bottom" id="Message" order="0" />
271
+      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
272
+      <window_info anchor="bottom" id="Find" order="1" />
273
+    </layout>
274
+  </component>
275
+  <component name="TypeScriptGeneratedFilesManager">
276
+    <option name="version" value="1" />
277
+  </component>
278
+  <component name="VcsContentAnnotationSettings">
279
+    <option name="myLimit" value="2678400000" />
280
+  </component>
281
+  <component name="editorHistoryManager">
282
+    <entry file="file://$PROJECT_DIR$/main/java/com/zipcoder/payment/Payment.java">
283
+      <provider selected="true" editor-type-id="text-editor" />
284
+    </entry>
285
+    <entry file="file://$PROJECT_DIR$/main/java/com/zipcoder/payment/CreditCard.java">
286
+      <provider selected="true" editor-type-id="text-editor" />
287
+    </entry>
288
+    <entry file="file://$PROJECT_DIR$/main/java/com/zipcoder/payment/PayPal.java">
289
+      <provider selected="true" editor-type-id="text-editor">
290
+        <state relative-caret-position="-10" />
291
+      </provider>
292
+    </entry>
293
+    <entry file="file://$PROJECT_DIR$/main/java/com/zipcoder/payment/Check.java">
294
+      <provider selected="true" editor-type-id="text-editor">
295
+        <state relative-caret-position="279">
296
+          <caret line="21" lean-forward="true" selection-start-line="21" selection-end-line="21" />
297
+        </state>
298
+      </provider>
299
+    </entry>
300
+    <entry file="file://$PROJECT_DIR$/test/java/com/zipcoder/payment/CreditCardTest.java">
301
+      <provider selected="true" editor-type-id="text-editor" />
302
+    </entry>
303
+    <entry file="file://$PROJECT_DIR$/test/java/com/zipcoder/payment/PayPalTest.java">
304
+      <provider selected="true" editor-type-id="text-editor">
305
+        <state relative-caret-position="402">
306
+          <caret line="64" column="2" lean-forward="true" selection-start-line="64" selection-start-column="2" selection-end-line="64" selection-end-column="2" />
307
+        </state>
308
+      </provider>
309
+    </entry>
310
+  </component>
311
+  <component name="masterDetails">
312
+    <states>
313
+      <state key="ProjectJDKs.UI">
314
+        <settings>
315
+          <last-edited>1.8</last-edited>
316
+          <splitter-proportions>
317
+            <option name="proportions">
318
+              <list>
319
+                <option value="0.2" />
320
+              </list>
321
+            </option>
322
+          </splitter-proportions>
323
+        </settings>
324
+      </state>
325
+    </states>
326
+  </component>
327
+</project>

Двоичные данные
src/main/.DS_Store Просмотреть файл


Двоичные данные
src/main/java/.DS_Store Просмотреть файл


Двоичные данные
src/main/java/com/.DS_Store Просмотреть файл


Двоичные данные
src/main/java/com/zipcoder/.DS_Store Просмотреть файл


Двоичные данные
src/main/java/com/zipcoder/payment/.DS_Store Просмотреть файл


+ 59
- 0
src/main/java/com/zipcoder/payment/Check.java Просмотреть файл

@@ -0,0 +1,59 @@
1
+package com.zipcoder.payment;
2
+
3
+public class Check implements Payment {
4
+    long id;
5
+    String payerName;
6
+    String routingNumber;
7
+    String accountNumber;
8
+
9
+    public Check(long id, String payerName, String routingNumber, String accountNumber) {
10
+        this.id = id;
11
+        this.payerName = payerName;
12
+        this.routingNumber = routingNumber;
13
+        this.accountNumber = accountNumber;
14
+    }
15
+
16
+    public Check() {
17
+    }
18
+
19
+    public long getId() {
20
+        return id;
21
+    }
22
+
23
+    public void setId(long id) {
24
+        this.id = id;
25
+    }
26
+
27
+    public String getPayerName() {
28
+        return payerName;
29
+    }
30
+
31
+    public void setPayerName(String payerName) {
32
+        this.payerName = payerName;
33
+    }
34
+
35
+    public String getRoutingNumber() {
36
+        return routingNumber;
37
+    }
38
+
39
+    public void setRoutingNumber(String routingNumber) {
40
+        this.routingNumber = routingNumber;
41
+    }
42
+
43
+    public String getAccountNumber() {
44
+        return accountNumber;
45
+    }
46
+
47
+    public void setAccountNumber(String accountNumber) {
48
+        this.accountNumber = accountNumber;
49
+    }
50
+
51
+    public String getShortDescription() {
52
+        return "Check " + payerName + " ***" + accountNumber.substring(accountNumber.length() - 4, accountNumber.length());
53
+    }
54
+
55
+    public int compareTo(Payment p){
56
+        return this.getShortDescription().compareTo(p.getShortDescription());
57
+
58
+    }
59
+}

+ 71
- 0
src/main/java/com/zipcoder/payment/CreditCard.java Просмотреть файл

@@ -0,0 +1,71 @@
1
+package com.zipcoder.payment;
2
+
3
+public class CreditCard implements Payment {
4
+
5
+    long id;
6
+    String payerName;
7
+    String number;
8
+    int expiredMonth;
9
+    int expiredYear;
10
+
11
+    public CreditCard(long id, String payerName, String number, int expiredMonth, int expiredYear) {
12
+        this.id = id;
13
+        this.payerName = payerName;
14
+        this.number = number;
15
+        this.expiredMonth = expiredMonth;
16
+        this.expiredYear = expiredYear;
17
+    }
18
+
19
+    public CreditCard() {
20
+    }
21
+
22
+    public long getId(){
23
+        return id;
24
+    }
25
+    public void setId(long id){
26
+        this.id = id;
27
+
28
+    }
29
+    public String getPayerName(){
30
+        return payerName;
31
+    }
32
+
33
+    public void setPayerName(String payerName){
34
+        this.payerName = payerName;
35
+    }
36
+
37
+    public void setNumber(String number){
38
+        this.number = number;
39
+    }
40
+
41
+    public String getNumber(){
42
+        return number;
43
+    }
44
+
45
+    public void setExpiredMonth(int expiredMonth){
46
+        this.expiredMonth = expiredMonth;
47
+    }
48
+    public int getExpiredMonth(){
49
+        return expiredMonth;
50
+    }
51
+
52
+    public void setExpiredYear(int expiredYear){
53
+        this.expiredYear = expiredYear;
54
+    }
55
+
56
+    public int getExpiredYear(){
57
+        return expiredYear;
58
+    }
59
+
60
+    public String getShortDescription(){
61
+        return "CC" + payerName + " " +  number.substring(number.length()-5, number.length()-1) + " " + expiredMonth + "/" + expiredYear;
62
+    }
63
+    public int compareTo(Payment p){
64
+        return this.getShortDescription().compareTo(p.getShortDescription());
65
+
66
+    }
67
+
68
+
69
+
70
+
71
+}

+ 51
- 0
src/main/java/com/zipcoder/payment/PayPal.java Просмотреть файл

@@ -0,0 +1,51 @@
1
+package com.zipcoder.payment;
2
+
3
+public class PayPal implements Payment{
4
+    long id;
5
+    String payerName;
6
+    String email;
7
+
8
+    public PayPal(long id, String payerName, String email) {
9
+        this.id = id;
10
+        this.payerName = payerName;
11
+        this.email = email;
12
+    }
13
+
14
+    public PayPal() {
15
+    }
16
+
17
+    public long getId() {
18
+        return id;
19
+    }
20
+
21
+    public void setId(long id) {
22
+        this.id = id;
23
+    }
24
+
25
+    public String getPayerName() {
26
+        return payerName;
27
+    }
28
+
29
+    public void setPayerName(String payerName) {
30
+        this.payerName = payerName;
31
+    }
32
+
33
+    public String getEmail() {
34
+        return email;
35
+    }
36
+
37
+    public void setEmail(String email) {
38
+        this.email = email;
39
+    }
40
+
41
+    public String getShortDescription(){
42
+        return "PayPal " + payerName + " " +  email;
43
+
44
+    }
45
+
46
+    public int compareTo(Payment p){
47
+       return this.getShortDescription().compareTo(p.getShortDescription());
48
+
49
+    }
50
+
51
+}

+ 15
- 0
src/main/java/com/zipcoder/payment/Payment.java Просмотреть файл

@@ -0,0 +1,15 @@
1
+package com.zipcoder.payment;
2
+
3
+public interface Payment extends Comparable<Payment>{
4
+
5
+
6
+long getId();
7
+String getPayerName();
8
+String getShortDescription();
9
+
10
+
11
+
12
+
13
+
14
+
15
+}

+ 31
- 1
src/main/java/com/zipcoder/payment/PaymentPresenter.java Просмотреть файл

@@ -1,6 +1,36 @@
1 1
 package com.zipcoder.payment;
2 2
 
3
+import java.util.Arrays;
4
+
3 5
 public class PaymentPresenter {
4 6
 
5 7
 
6
-}
8
+    public String toString(Payment[] p) {
9
+        Arrays.sort(p);
10
+        StringBuilder str = new StringBuilder();
11
+        for (Payment payment : p) {
12
+            str.append(payment.getShortDescription() + "\n");
13
+        }
14
+        return str.toString();
15
+    }
16
+
17
+    public String toStringByPayerName(Payment[] payments) {
18
+        Arrays.sort(payments, new PaymentSortByPayer());
19
+
20
+        return createString(payments);
21
+    }
22
+
23
+    public String toStringById(Payment[] payments) {
24
+        Arrays.sort(payments);
25
+
26
+        return createString(payments);
27
+    }
28
+
29
+    private String createString(Payment[] payments) {
30
+        String str = "";
31
+        for (Payment payment : payments) {
32
+            str += payment.getShortDescription() + "\n";
33
+        }
34
+        return str;
35
+    }
36
+}

+ 11
- 0
src/main/java/com/zipcoder/payment/PaymentSortByPayer.java Просмотреть файл

@@ -0,0 +1,11 @@
1
+package com.zipcoder.payment;
2
+import java.util.Comparator;
3
+
4
+public class PaymentSortByPayer implements Comparator<Payment> {
5
+
6
+
7
+    public int compare(Payment p1, Payment p2){
8
+        return p1.getPayerName().compareTo(p2.getPayerName());
9
+
10
+    }
11
+}

+ 81
- 0
src/test/java/com/zipcoder/payment/CheckTest.java Просмотреть файл

@@ -0,0 +1,81 @@
1
+package com.zipcoder.payment;
2
+
3
+import org.junit.jupiter.api.Test;
4
+
5
+import static org.junit.jupiter.api.Assertions.*;
6
+
7
+class CheckTest {
8
+
9
+    @Test
10
+    void getId() {
11
+        Check cc = new Check();
12
+        cc.setId(2348);
13
+        long actual = cc.getId();
14
+        long expected = 2348;
15
+        assertEquals(actual, expected);
16
+    }
17
+
18
+    @Test
19
+    void setId() {
20
+        Check cc = new Check();
21
+        cc.setId(2348);
22
+        long actual = cc.getId();
23
+        long expected = 2348;
24
+        assertEquals(actual, expected);
25
+    }
26
+
27
+    @Test
28
+    void getPayerName() {
29
+        Check cc = new Check();
30
+        cc.setPayerName("Vince");
31
+        String actual = cc.getPayerName();
32
+        String expected = "Vince";
33
+        assertEquals(actual, expected);
34
+    }
35
+
36
+    @Test
37
+    void setPayerName() {
38
+        Check cc = new Check();
39
+        cc.setPayerName("Vince");
40
+        String actual = cc.getPayerName();
41
+        String expected = "Vince";
42
+        assertEquals(actual, expected);
43
+    }
44
+
45
+    @Test
46
+    void getRoutingNumber() {
47
+        Check cc = new Check();
48
+        cc.setRoutingNumber("Vince");
49
+        String actual = cc.getRoutingNumber();
50
+        String expected = "Vince";
51
+        assertEquals(actual, expected);
52
+    }
53
+
54
+    @Test
55
+    void setRoutingNumber() {
56
+        Check cc = new Check();
57
+        cc.setRoutingNumber("Vince");
58
+        String actual = cc.getRoutingNumber();
59
+        String expected = "Vince";
60
+        assertEquals(actual, expected);
61
+    }
62
+
63
+    @Test
64
+    void getAccountNumber() {
65
+        Check cc = new Check();
66
+        cc.setAccountNumber("Vince");
67
+        String actual = cc.getAccountNumber();
68
+        String expected = "Vince";
69
+        assertEquals(actual, expected);
70
+    }
71
+
72
+    @Test
73
+    void setAccountNumber() {
74
+        Check cc = new Check();
75
+        cc.setAccountNumber("Vince");
76
+        String actual = cc.getAccountNumber();
77
+        String expected = "Vince";
78
+        assertEquals(actual, expected);
79
+    }
80
+
81
+}

+ 105
- 0
src/test/java/com/zipcoder/payment/CreditCardTest.java Просмотреть файл

@@ -0,0 +1,105 @@
1
+package com.zipcoder.payment;
2
+
3
+import org.junit.jupiter.api.Test;
4
+
5
+import static org.junit.jupiter.api.Assertions.*;
6
+
7
+class CreditCardTest {
8
+
9
+    @Test
10
+    void getId() {
11
+        CreditCard cc = new CreditCard();
12
+        cc.setId(2348);
13
+        long actual = cc.getId();
14
+        long expected = 2348;
15
+        assertEquals(actual, expected);
16
+
17
+    }
18
+
19
+    @Test
20
+    void setId() {
21
+        CreditCard cc = new CreditCard();
22
+        cc.setId(5555);
23
+        long actual = cc.getId();
24
+        long expected = 5555;
25
+        assertEquals(actual, expected);
26
+    }
27
+
28
+    @Test
29
+    void getPayerName() {
30
+        CreditCard cc = new CreditCard();
31
+        cc.setPayerName("Vince");
32
+        String actual = cc.getPayerName();
33
+        String expected = "Vince";
34
+        assertEquals(actual, expected);
35
+    }
36
+
37
+    @Test
38
+    void setPayerName() {
39
+
40
+        CreditCard cc = new CreditCard();
41
+        cc.setPayerName("Ben");
42
+        String actual = cc.getPayerName();
43
+        String expected = "Ben";
44
+        assertEquals(actual, expected);
45
+    }
46
+    @Test
47
+    void getNumber() {
48
+
49
+        CreditCard cc = new CreditCard();
50
+        cc.setNumber("444");
51
+        String actual = cc.getNumber();
52
+        String expected = "444";
53
+        assertEquals(actual, expected);
54
+    }
55
+    @Test
56
+    void setNumber() {
57
+
58
+        CreditCard cc = new CreditCard();
59
+        cc.setNumber("555");
60
+        String actual = cc.getNumber();
61
+        String expected = "555";
62
+        assertEquals(actual, expected);
63
+    }
64
+
65
+    @Test
66
+    void getExpiredMonth() {
67
+
68
+        CreditCard cc = new CreditCard();
69
+        cc.setExpiredMonth(12);
70
+        int actual = cc.getExpiredMonth();
71
+        int expected = 12;
72
+        assertEquals(actual, expected);
73
+    }
74
+    @Test
75
+    void setExpiredMonth() {
76
+
77
+        CreditCard cc = new CreditCard();
78
+        cc.setExpiredMonth(7);
79
+        int actual = cc.getExpiredMonth();
80
+        int expected = 7;
81
+        assertEquals(actual, expected);
82
+    }
83
+
84
+    @Test
85
+    void getExpiredYear() {
86
+
87
+        CreditCard cc = new CreditCard();
88
+        cc.setExpiredYear(88);
89
+        int actual = cc.getExpiredYear();
90
+        int expected = 88;
91
+        assertEquals(actual, expected);
92
+    }
93
+    @Test
94
+    void setExpiredYear() {
95
+
96
+        CreditCard cc = new CreditCard();
97
+        cc.setExpiredYear(77);
98
+        int actual = cc.getExpiredYear();
99
+        int expected = 77;
100
+        assertEquals(actual, expected);
101
+    }
102
+
103
+
104
+
105
+}

+ 71
- 0
src/test/java/com/zipcoder/payment/PayPalTest.java Просмотреть файл

@@ -0,0 +1,71 @@
1
+package com.zipcoder.payment;
2
+
3
+import org.junit.jupiter.api.Test;
4
+
5
+import static org.junit.jupiter.api.Assertions.*;
6
+
7
+class PayPalTest {
8
+
9
+    @Test
10
+    void getId() {
11
+        PayPal cc = new PayPal();
12
+        cc.setId(2348);
13
+        long actual = cc.getId();
14
+        long expected = 2348;
15
+        assertEquals(actual, expected);
16
+
17
+    }
18
+
19
+    @Test
20
+    void setId() {
21
+        PayPal cc = new PayPal();
22
+        cc.setId(5555);
23
+        long actual = cc.getId();
24
+        long expected = 5555;
25
+        assertEquals(actual, expected);
26
+    }
27
+
28
+    @Test
29
+    void getPayerName() {
30
+        PayPal cc = new PayPal();
31
+        cc.setPayerName("Vince");
32
+        String actual = cc.getPayerName();
33
+        String expected = "Vince";
34
+        assertEquals(actual, expected);
35
+    }
36
+
37
+    @Test
38
+    void setPayerName() {
39
+        PayPal cc = new PayPal();
40
+        cc.setPayerName("Vince");
41
+        String actual = cc.getPayerName();
42
+        String expected = "Vince";
43
+        assertEquals(actual, expected);
44
+    }
45
+
46
+    @Test
47
+    void setEmail() {
48
+
49
+        PayPal cc = new PayPal();
50
+        cc.setEmail("Ben");
51
+        String actual = cc.getEmail();
52
+        String expected = "Ben";
53
+        assertEquals(actual, expected);
54
+    }
55
+    @Test
56
+    void getEmail() {
57
+        PayPal cc = new PayPal();
58
+        cc.setEmail("Vince");
59
+        String actual = cc.getEmail();
60
+        String expected = "Vince";
61
+        assertEquals(actual, expected);
62
+    }
63
+
64
+    @Test
65
+    void compareTo() {
66
+        Payment pp = new PayPal(1, "Tia Mowry", "tia@mowry.com");
67
+        Payment cc = new Check(1, "Tia Mowry", "00004551","00004551" );
68
+
69
+        assertTrue(pp.compareTo(cc) > 0);
70
+    }
71
+}

+ 58
- 2
src/test/java/com/zipcoder/payment/PaymentPresenterTest.java Просмотреть файл

@@ -1,4 +1,60 @@
1 1
 package com.zipcoder.payment;
2 2
 
3
-public class PaymentPresenterTest {
4
-}
3
+import org.junit.jupiter.api.Test;
4
+
5
+import static org.junit.jupiter.api.Assertions.*;
6
+
7
+class PaymentPresenterTest {
8
+
9
+    @Test
10
+    void toStringTest() {
11
+        Payment[] payments = new Payment[0];
12
+        PaymentPresenter presenter = new PaymentPresenter();
13
+        String expected = "";
14
+
15
+        String actual = presenter.toString(payments);
16
+
17
+        assertEquals(expected, actual);
18
+    }
19
+
20
+    @Test
21
+    void toStringTest2() {
22
+        Payment paypal = new PayPal(4L, "Tia Mowry", "tia@mowry.com");
23
+        Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551");
24
+        Payment[] payments = new Payment[]{paypal, check};
25
+
26
+        PaymentPresenter presenter = new PaymentPresenter();
27
+        String expected = "Check Tia Mowry ***4551\nPayPal Tia Mowry tia@mowry.com\n";
28
+
29
+        String actual = presenter.toString(payments);
30
+        assertEquals(expected, actual);
31
+    }
32
+
33
+    @Test
34
+    void toStringByPayerNameTest() {
35
+        Payment paypal = new PayPal(4L, "Tamara Mowry", "tamara@mowry.com");
36
+        Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551");
37
+        Payment[] payments = new Payment[]{check, paypal};
38
+
39
+        PaymentPresenter presenter = new PaymentPresenter();
40
+        String expected = "PayPal Tamara Mowry tamara@mowry.com\nCheck Tia Mowry ***4551\n";
41
+
42
+        String actual = presenter.toStringByPayerName(payments);
43
+        assertEquals(expected, actual);
44
+    }
45
+
46
+    @Test
47
+    void toStringByIdTest() {
48
+        Payment paypal = new PayPal(120L, "Tamara Mowry", "tamara@mowry.com");
49
+        Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551");
50
+        Payment[] payments = new Payment[]{paypal, check};
51
+
52
+
53
+        PaymentPresenter presenter = new PaymentPresenter();
54
+        String expected = "Check Tia Mowry ***4551\nPayPal Tamara Mowry tamara@mowry.com\n";
55
+
56
+        String actual = presenter.toStringById(payments);
57
+        assertEquals(expected, actual);
58
+
59
+    }
60
+}

+ 16
- 0
src/test/java/com/zipcoder/payment/PaymentSortByPayerTest.java Просмотреть файл

@@ -0,0 +1,16 @@
1
+package com.zipcoder.payment;
2
+
3
+import org.junit.jupiter.api.Test;
4
+
5
+import static org.junit.jupiter.api.Assertions.*;
6
+
7
+class PaymentSortByPayerTest {
8
+
9
+    @Test
10
+    void compare() {
11
+        PaymentSortByPayer ps = new PaymentSortByPayer();
12
+        Payment pp = new PayPal(1, "Tia Mowry", "tia@mowry.com");
13
+        Payment cc = new Check(1, "Tia Mowry", "00004551","00004551" );
14
+        assertTrue(ps.compare(pp,cc) == 0);
15
+    }
16
+}