Преглед на файлове

created anonymous class

Eric Foster преди 6 години
родител
ревизия
9f7d1f137d

+ 49
- 57
ZCWLambdas/.idea/workspace.xml Целия файл

@@ -2,13 +2,11 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="ca475bf5-bfb8-47c8-9af1-d8f2b40d1985" name="Default" comment="">
5
-      <change afterPath="$PROJECT_DIR$/src/test/java/PersonTest.java" afterDir="false" />
6
-      <change afterPath="$PROJECT_DIR$/src/test/java/TestPersonAgeRangeTest.java" afterDir="false" />
7 5
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
8
-      <change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
9 6
       <change beforePath="$PROJECT_DIR$/src/main/java/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Main.java" afterDir="false" />
10
-      <change beforePath="$PROJECT_DIR$/src/main/java/Person.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Person.java" afterDir="false" />
11
-      <change beforePath="$PROJECT_DIR$/src/main/java/TestPersonAge.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/TestPersonAgeRange.java" afterDir="false" />
7
+      <change beforePath="$PROJECT_DIR$/src/main/java/PrintPersons.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/PrintPersons.java" afterDir="false" />
8
+      <change beforePath="$PROJECT_DIR$/src/main/java/TestPersonAgeRange.java" beforeDir="false" />
9
+      <change beforePath="$PROJECT_DIR$/src/test/java/TestPersonAgeRangeTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/TestPrintPersons.java" afterDir="false" />
12 10
     </list>
13 11
     <ignored path="$PROJECT_DIR$/target/" />
14 12
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -49,20 +47,11 @@
49 47
       <file leaf-file-name="PrintPersons.java" pinned="false" current-in-tab="false">
50 48
         <entry file="file://$PROJECT_DIR$/src/main/java/PrintPersons.java">
51 49
           <provider selected="true" editor-type-id="text-editor">
52
-            <state relative-caret-position="105">
53
-              <caret line="7" column="13" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
54
-            </state>
55
-          </provider>
56
-        </entry>
57
-      </file>
58
-      <file leaf-file-name="TestPersonAgeRange.java" pinned="false" current-in-tab="false">
59
-        <entry file="file://$PROJECT_DIR$/src/main/java/TestPersonAgeRange.java">
60
-          <provider selected="true" editor-type-id="text-editor">
61
-            <state relative-caret-position="30">
62
-              <caret line="2" column="26" selection-start-line="2" selection-start-column="26" selection-end-line="2" selection-end-column="26" />
50
+            <state relative-caret-position="180">
51
+              <caret line="12" column="6" lean-forward="true" selection-start-line="12" selection-start-column="6" selection-end-line="12" selection-end-column="6" />
63 52
               <folding>
64
-                <element signature="e#163#164#0" expanded="true" />
65
-                <element signature="e#226#227#0" expanded="true" />
53
+                <element signature="e#219#220#0" expanded="true" />
54
+                <element signature="e#290#291#0" expanded="true" />
66 55
               </folding>
67 56
             </state>
68 57
           </provider>
@@ -76,8 +65,8 @@
76 65
       <file leaf-file-name="Main.java" pinned="false" current-in-tab="false">
77 66
         <entry file="file://$PROJECT_DIR$/src/main/java/Main.java">
78 67
           <provider selected="true" editor-type-id="text-editor">
79
-            <state relative-caret-position="150">
80
-              <caret line="10" column="113" lean-forward="true" selection-start-line="10" selection-start-column="23" selection-end-line="10" selection-end-column="113" />
68
+            <state relative-caret-position="180">
69
+              <caret line="12" column="8" lean-forward="true" selection-start-line="12" selection-start-column="8" selection-end-line="12" selection-end-column="8" />
81 70
               <folding>
82 71
                 <element signature="imports" expanded="true" />
83 72
               </folding>
@@ -85,11 +74,11 @@
85 74
           </provider>
86 75
         </entry>
87 76
       </file>
88
-      <file leaf-file-name="TestPersonAgeRangeTest.java" pinned="false" current-in-tab="true">
89
-        <entry file="file://$PROJECT_DIR$/src/test/java/TestPersonAgeRangeTest.java">
77
+      <file leaf-file-name="TestPrintPersons.java" pinned="false" current-in-tab="true">
78
+        <entry file="file://$PROJECT_DIR$/src/test/java/TestPrintPersons.java">
90 79
           <provider selected="true" editor-type-id="text-editor">
91
-            <state relative-caret-position="270">
92
-              <caret line="18" column="114" selection-start-line="18" selection-start-column="114" selection-end-line="18" selection-end-column="114" />
80
+            <state relative-caret-position="240">
81
+              <caret line="16" column="9" lean-forward="true" selection-start-line="16" selection-start-column="9" selection-end-line="16" selection-end-column="9" />
93 82
               <folding>
94 83
                 <element signature="imports" expanded="true" />
95 84
               </folding>
@@ -117,14 +106,15 @@
117 106
         <option value="$PROJECT_DIR$/src/main/java/PersonSearch.java" />
118 107
         <option value="$PROJECT_DIR$/src/main/java/CheckPerson.java" />
119 108
         <option value="$PROJECT_DIR$/src/main/java/Persons.java" />
120
-        <option value="$PROJECT_DIR$/src/main/java/PrintPersons.java" />
121 109
         <option value="$PROJECT_DIR$/src/main/java/TestPerson.java" />
122 110
         <option value="$PROJECT_DIR$/src/main/java/TestPersonAge.java" />
123
-        <option value="$PROJECT_DIR$/src/main/java/TestPersonAgeRange.java" />
124 111
         <option value="$PROJECT_DIR$/src/test/java/PersonTest.java" />
125 112
         <option value="$PROJECT_DIR$/src/main/java/Person.java" />
126
-        <option value="$PROJECT_DIR$/src/main/java/Main.java" />
127 113
         <option value="$PROJECT_DIR$/src/test/java/TestPersonAgeRangeTest.java" />
114
+        <option value="$PROJECT_DIR$/src/main/java/TestPersonAgeRange.java" />
115
+        <option value="$PROJECT_DIR$/src/main/java/PrintPersons.java" />
116
+        <option value="$PROJECT_DIR$/src/main/java/Main.java" />
117
+        <option value="$PROJECT_DIR$/src/test/java/TestPrintPersons.java" />
128 118
       </list>
129 119
     </option>
130 120
   </component>
@@ -146,9 +136,9 @@
146 136
   </component>
147 137
   <component name="ProjectFrameBounds">
148 138
     <option name="x" value="-301" />
149
-    <option name="y" value="-1045" />
139
+    <option name="y" value="-1057" />
150 140
     <option name="width" value="1862" />
151
-    <option name="height" value="1030" />
141
+    <option name="height" value="993" />
152 142
   </component>
153 143
   <component name="ProjectLevelVcsManager" settingsEditedManually="true">
154 144
     <ConfirmationsSetting value="2" id="Add" />
@@ -290,12 +280,12 @@
290 280
       </option>
291 281
       <patterns />
292 282
     </configuration>
293
-    <configuration name="TestPersonAgeRangeTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
283
+    <configuration name="TestPrintPersons" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
294 284
       <module name="ZCW-Lambdas" />
295 285
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
296 286
       <option name="ALTERNATIVE_JRE_PATH" />
297 287
       <option name="PACKAGE_NAME" value="" />
298
-      <option name="MAIN_CLASS_NAME" value="TestPersonAgeRangeTest" />
288
+      <option name="MAIN_CLASS_NAME" value="TestPrintPersons" />
299 289
       <option name="METHOD_NAME" />
300 290
       <option name="TEST_OBJECT" value="class" />
301 291
       <option name="VM_PARAMETERS" value="-ea" />
@@ -349,13 +339,13 @@
349 339
       <item itemvalue="JUnit.PersonTest" />
350 340
       <item itemvalue="JUnit.PersonTest.getAgeTest" />
351 341
       <item itemvalue="Application.Main" />
352
-      <item itemvalue="JUnit.TestPersonAgeRangeTest" />
342
+      <item itemvalue="JUnit.TestPrintPersons" />
353 343
       <item itemvalue="JUnit.All in ZCW-Lambdas" />
354 344
     </list>
355 345
     <recent_temporary>
356 346
       <list>
357 347
         <item itemvalue="JUnit.All in ZCW-Lambdas" />
358
-        <item itemvalue="JUnit.TestPersonAgeRangeTest" />
348
+        <item itemvalue="JUnit.TestPrintPersons" />
359 349
         <item itemvalue="Application.Main" />
360 350
         <item itemvalue="JUnit.PersonTest" />
361 351
         <item itemvalue="JUnit.PersonTest.getAgeTest" />
@@ -374,7 +364,7 @@
374 364
       <updated>1529496977466</updated>
375 365
       <workItem from="1529496978846" duration="59000" />
376 366
       <workItem from="1530014838012" duration="1914000" />
377
-      <workItem from="1530016993032" duration="3209000" />
367
+      <workItem from="1530016993032" duration="4256000" />
378 368
     </task>
379 369
     <servers />
380 370
   </component>
@@ -388,9 +378,15 @@
388 378
     <history-entry file="PersonTest - 2018.06.26 at 09h 59m 49s.xml">
389 379
       <configuration name="PersonTest" configurationId="JUnit" />
390 380
     </history-entry>
381
+    <history-entry file="TestPersonAgeRangeTest - 2018.06.26 at 10h 10m 13s.xml">
382
+      <configuration name="TestPersonAgeRangeTest" configurationId="JUnit" />
383
+    </history-entry>
384
+    <history-entry file="All_in_ZCW-Lambdas - 2018.06.26 at 10h 10m 27s.xml">
385
+      <configuration name="All in ZCW-Lambdas" configurationId="JUnit" />
386
+    </history-entry>
391 387
   </component>
392 388
   <component name="TimeTrackingManager">
393
-    <option name="totallyTimeSpent" value="5182000" />
389
+    <option name="totallyTimeSpent" value="6229000" />
394 390
   </component>
395 391
   <component name="ToolWindowManager">
396 392
     <frame x="-301" y="-1045" width="1862" height="1030" extended-state="0" />
@@ -449,6 +445,10 @@
449 445
       <provider selected="true" editor-type-id="text-editor">
450 446
         <state relative-caret-position="105">
451 447
           <caret line="7" column="13" lean-forward="true" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
448
+          <folding>
449
+            <element signature="e#219#220#0" expanded="true" />
450
+            <element signature="e#290#291#0" expanded="true" />
451
+          </folding>
452 452
         </state>
453 453
       </provider>
454 454
     </entry>
@@ -469,10 +469,6 @@
469 469
       <provider selected="true" editor-type-id="text-editor">
470 470
         <state>
471 471
           <caret column="13" selection-start-column="13" selection-end-column="13" />
472
-          <folding>
473
-            <element signature="e#163#164#0" expanded="true" />
474
-            <element signature="e#226#227#0" expanded="true" />
475
-          </folding>
476 472
         </state>
477 473
       </provider>
478 474
     </entry>
@@ -491,13 +487,6 @@
491 487
         </state>
492 488
       </provider>
493 489
     </entry>
494
-    <entry file="file://$PROJECT_DIR$/src/main/java/PrintPersons.java">
495
-      <provider selected="true" editor-type-id="text-editor">
496
-        <state relative-caret-position="105">
497
-          <caret line="7" column="13" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
498
-        </state>
499
-      </provider>
500
-    </entry>
501 490
     <entry file="file://$PROJECT_DIR$/src/test/java/PersonTest.java">
502 491
       <provider selected="true" editor-type-id="text-editor">
503 492
         <state relative-caret-position="255">
@@ -509,30 +498,33 @@
509 498
       </provider>
510 499
     </entry>
511 500
     <entry file="file://$PROJECT_DIR$/src/main/java/TestPersonAgeRange.java">
501
+      <provider selected="true" editor-type-id="text-editor" />
502
+    </entry>
503
+    <entry file="file://$PROJECT_DIR$/src/main/java/Main.java">
512 504
       <provider selected="true" editor-type-id="text-editor">
513
-        <state relative-caret-position="30">
514
-          <caret line="2" column="26" selection-start-line="2" selection-start-column="26" selection-end-line="2" selection-end-column="26" />
505
+        <state relative-caret-position="180">
506
+          <caret line="12" column="8" lean-forward="true" selection-start-line="12" selection-start-column="8" selection-end-line="12" selection-end-column="8" />
515 507
           <folding>
516
-            <element signature="e#163#164#0" expanded="true" />
517
-            <element signature="e#226#227#0" expanded="true" />
508
+            <element signature="imports" expanded="true" />
518 509
           </folding>
519 510
         </state>
520 511
       </provider>
521 512
     </entry>
522
-    <entry file="file://$PROJECT_DIR$/src/main/java/Main.java">
513
+    <entry file="file://$PROJECT_DIR$/src/main/java/PrintPersons.java">
523 514
       <provider selected="true" editor-type-id="text-editor">
524
-        <state relative-caret-position="150">
525
-          <caret line="10" column="113" lean-forward="true" selection-start-line="10" selection-start-column="23" selection-end-line="10" selection-end-column="113" />
515
+        <state relative-caret-position="180">
516
+          <caret line="12" column="6" lean-forward="true" selection-start-line="12" selection-start-column="6" selection-end-line="12" selection-end-column="6" />
526 517
           <folding>
527
-            <element signature="imports" expanded="true" />
518
+            <element signature="e#219#220#0" expanded="true" />
519
+            <element signature="e#290#291#0" expanded="true" />
528 520
           </folding>
529 521
         </state>
530 522
       </provider>
531 523
     </entry>
532
-    <entry file="file://$PROJECT_DIR$/src/test/java/TestPersonAgeRangeTest.java">
524
+    <entry file="file://$PROJECT_DIR$/src/test/java/TestPrintPersons.java">
533 525
       <provider selected="true" editor-type-id="text-editor">
534
-        <state relative-caret-position="270">
535
-          <caret line="18" column="114" selection-start-line="18" selection-start-column="114" selection-end-line="18" selection-end-column="114" />
526
+        <state relative-caret-position="240">
527
+          <caret line="16" column="9" lean-forward="true" selection-start-line="16" selection-start-column="9" selection-end-line="16" selection-end-column="9" />
536 528
           <folding>
537 529
             <element signature="imports" expanded="true" />
538 530
           </folding>

+ 1
- 2
ZCWLambdas/src/main/java/Main.java Целия файл

@@ -11,8 +11,7 @@ public class Main {
11 11
         personList.add(new Person("Jim", LocalDate.of(1970, Month.JANUARY, 01), Person.Sex.MALE, "jim@gmail.com"));
12 12
         personList.add(new Person("Joann", LocalDate.of(2000, Month.JANUARY, 01), Person.Sex.FEMALE, "joann@gmail.com"));
13 13
 
14
-        CheckPerson tester = new TestPersonAgeRange();
15 14
         PrintPersons printer = new PrintPersons();
16
-        printer.printPersons(personList, tester);
15
+        printer.printPersons(personList, printer.check);
17 16
     }
18 17
 }

+ 10
- 0
ZCWLambdas/src/main/java/PrintPersons.java Целия файл

@@ -1,6 +1,16 @@
1 1
 import java.util.List;
2 2
 
3 3
 public class PrintPersons {
4
+
5
+    CheckPerson check = new CheckPerson() {
6
+        @Override
7
+        public boolean test(Person p) {
8
+            int low = 20;
9
+            int high = 40;
10
+            return (low <= p.getAge() && p.getAge() < high);
11
+        }
12
+    };
13
+
4 14
     public static void printPersons(List<Person> roster, CheckPerson tester) {
5 15
         for (Person p : roster) {
6 16
             if (tester.test(p)) {

+ 0
- 10
ZCWLambdas/src/main/java/TestPersonAgeRange.java Целия файл

@@ -1,10 +0,0 @@
1
-public class TestPersonAgeRange implements CheckPerson {
2
-    private int low = 20;
3
-    private int high = 40;
4
-
5
-    @Override
6
-    public boolean test(Person p) {
7
-        return (low <= p.getAge() && p.getAge() < high);
8
-    }
9
-
10
-}

ZCWLambdas/src/test/java/TestPersonAgeRangeTest.java → ZCWLambdas/src/test/java/TestPrintPersons.java Целия файл

@@ -6,18 +6,18 @@ import java.time.Month;
6 6
 import static junit.framework.TestCase.assertTrue;
7 7
 import static org.junit.Assert.assertFalse;
8 8
 
9
-public class TestPersonAgeRangeTest {
9
+public class TestPrintPersons {
10 10
     @Test
11 11
     public void testTestPositive(){
12 12
         Person person = new Person("John", LocalDate.of(1990, Month.JANUARY, 01), Person.Sex.MALE, "johndoe@gmail.com");
13
-        TestPersonAgeRange tester = new TestPersonAgeRange();
14
-        assertTrue(tester.test(person));
13
+        PrintPersons tester = new PrintPersons();
14
+        assertTrue(tester.check.test(person));
15 15
     }
16 16
 
17 17
     @Test
18 18
     public void testTestNegative(){
19 19
         Person person = new Person("Jim", LocalDate.of(1970, Month.JANUARY, 01), Person.Sex.MALE, "jim@gmail.com");
20
-        TestPersonAgeRange tester = new TestPersonAgeRange();
21
-        assertFalse(tester.test(person));
20
+        PrintPersons tester = new PrintPersons();
21
+        assertFalse(tester.check.test(person));
22 22
     }
23 23
 }

BIN
ZCWLambdas/target/classes/Main.class Целия файл


BIN
ZCWLambdas/target/classes/PrintPersons$1.class Целия файл


BIN
ZCWLambdas/target/classes/PrintPersons.class Целия файл


BIN
ZCWLambdas/target/classes/TestPersonAgeRange.class Целия файл


BIN
ZCWLambdas/target/test-classes/TestPersonAgeRangeTest.class Целия файл


BIN
ZCWLambdas/target/test-classes/TestPrintPersons.class Целия файл