Browse Source

all tests Passing

Kibret Tecle 6 years ago
parent
commit
dc72023b4e

+ 143
- 125
.idea/workspace.xml View File

2
 <project version="4">
2
 <project version="4">
3
   <component name="ChangeListManager">
3
   <component name="ChangeListManager">
4
     <list default="true" id="e282cee1-bfe9-42a3-9794-9633eb4654d1" name="Default" comment="">
4
     <list default="true" id="e282cee1-bfe9-42a3-9794-9633eb4654d1" name="Default" comment="">
5
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
6
       <change beforePath="$PROJECT_DIR$/src/main/java/com/zipcodeconway/ConwayGameOfLife.java" afterPath="$PROJECT_DIR$/src/main/java/com/zipcodeconway/ConwayGameOfLife.java" />
5
       <change beforePath="$PROJECT_DIR$/src/main/java/com/zipcodeconway/ConwayGameOfLife.java" afterPath="$PROJECT_DIR$/src/main/java/com/zipcodeconway/ConwayGameOfLife.java" />
6
+      <change beforePath="$PROJECT_DIR$/src/test/java/com/zipcodeconway/ConwayGameOfLifeTest.java" afterPath="$PROJECT_DIR$/src/test/java/com/zipcodeconway/ConwayGameOfLifeTest.java" />
7
     </list>
7
     </list>
8
     <ignored path="$PROJECT_DIR$/target/" />
8
     <ignored path="$PROJECT_DIR$/target/" />
9
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
9
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
13
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
13
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
14
     <option name="LAST_RESOLUTION" value="IGNORE" />
14
     <option name="LAST_RESOLUTION" value="IGNORE" />
15
   </component>
15
   </component>
16
+  <component name="CoverageDataManager">
17
+    <SUITE FILE_PATH="coverage/ConwayGameOfLife$ConwayGameOfLifeTest_runTest1.coverage" NAME="ConwayGameOfLifeTest.runTest1 Coverage Results" MODIFIED="1520897845735" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false">
18
+      <FILTER>com.zipcodeconway.*</FILTER>
19
+    </SUITE>
20
+  </component>
16
   <component name="FileEditorManager">
21
   <component name="FileEditorManager">
17
-    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
18
-      <file leaf-file-name="SimpleWindow.java" pinned="false" current-in-tab="false">
19
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodeconway/SimpleWindow.java">
20
-          <provider selected="true" editor-type-id="text-editor">
21
-            <state relative-caret-position="255">
22
-              <caret line="17" column="42" lean-forward="false" selection-start-line="17" selection-start-column="42" selection-end-line="17" selection-end-column="42" />
23
-              <folding>
24
-                <element signature="imports" expanded="true" />
25
-              </folding>
26
-            </state>
27
-          </provider>
28
-        </entry>
29
-      </file>
30
-      <file leaf-file-name="ConwayGameOfLife.java" pinned="false" current-in-tab="true">
31
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodeconway/ConwayGameOfLife.java">
32
-          <provider selected="true" editor-type-id="text-editor">
33
-            <state relative-caret-position="214">
34
-              <caret line="68" column="4" lean-forward="false" selection-start-line="68" selection-start-column="4" selection-end-line="68" selection-end-column="4" />
35
-              <folding>
36
-                <element signature="e#269#270#0" expanded="true" />
37
-                <element signature="e#334#335#0" expanded="true" />
38
-                <element signature="e#1252#1253#0" expanded="true" />
39
-                <element signature="e#1288#1289#0" expanded="true" />
40
-              </folding>
41
-            </state>
42
-          </provider>
43
-        </entry>
44
-      </file>
45
-      <file leaf-file-name="ConwayGameOfLifeTest.java" pinned="false" current-in-tab="false">
46
-        <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodeconway/ConwayGameOfLifeTest.java">
47
-          <provider selected="true" editor-type-id="text-editor">
48
-            <state relative-caret-position="450">
49
-              <caret line="32" column="32" lean-forward="false" selection-start-line="32" selection-start-column="32" selection-end-line="32" selection-end-column="32" />
50
-              <folding />
51
-            </state>
52
-          </provider>
53
-        </entry>
54
-      </file>
55
-      <file leaf-file-name="ConwayLifeRandomat50.png" pinned="false" current-in-tab="false">
56
-        <entry file="file://$PROJECT_DIR$/ConwayLifeRandomat50.png">
57
-          <provider selected="true" editor-type-id="images">
58
-            <state />
59
-          </provider>
60
-        </entry>
61
-      </file>
62
-    </leaf>
22
+    <splitter split-orientation="horizontal" split-proportion="0.52879584">
23
+      <split-first>
24
+        <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
25
+          <file leaf-file-name="SimpleWindow.java" pinned="false" current-in-tab="false">
26
+            <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodeconway/SimpleWindow.java">
27
+              <provider selected="true" editor-type-id="text-editor">
28
+                <state relative-caret-position="255">
29
+                  <caret line="17" column="42" lean-forward="false" selection-start-line="17" selection-start-column="42" selection-end-line="17" selection-end-column="42" />
30
+                  <folding>
31
+                    <element signature="imports" expanded="true" />
32
+                  </folding>
33
+                </state>
34
+              </provider>
35
+            </entry>
36
+          </file>
37
+          <file leaf-file-name="ConwayGameOfLife.java" pinned="false" current-in-tab="true">
38
+            <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodeconway/ConwayGameOfLife.java">
39
+              <provider selected="true" editor-type-id="text-editor">
40
+                <state relative-caret-position="759">
41
+                  <caret line="55" column="9" lean-forward="true" selection-start-line="55" selection-start-column="9" selection-end-line="55" selection-end-column="9" />
42
+                  <folding />
43
+                </state>
44
+              </provider>
45
+            </entry>
46
+          </file>
47
+          <file leaf-file-name="ConwayLifeRandomat50.png" pinned="false" current-in-tab="false">
48
+            <entry file="file://$PROJECT_DIR$/ConwayLifeRandomat50.png">
49
+              <provider selected="true" editor-type-id="images">
50
+                <state />
51
+              </provider>
52
+            </entry>
53
+          </file>
54
+        </leaf>
55
+      </split-first>
56
+      <split-second>
57
+        <leaf>
58
+          <file leaf-file-name="ConwayGameOfLifeTest.java" pinned="false" current-in-tab="true">
59
+            <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodeconway/ConwayGameOfLifeTest.java">
60
+              <provider selected="true" editor-type-id="text-editor">
61
+                <state relative-caret-position="855">
62
+                  <caret line="60" column="0" lean-forward="false" selection-start-line="60" selection-start-column="0" selection-end-line="60" selection-end-column="0" />
63
+                  <folding />
64
+                </state>
65
+              </provider>
66
+            </entry>
67
+          </file>
68
+        </leaf>
69
+      </split-second>
70
+    </splitter>
63
   </component>
71
   </component>
64
   <component name="FileTemplateManagerImpl">
72
   <component name="FileTemplateManagerImpl">
65
     <option name="RECENT_TEMPLATES">
73
     <option name="RECENT_TEMPLATES">
98
         <option value="$PROJECT_DIR$/src/main/java/SimpleWindow.java" />
106
         <option value="$PROJECT_DIR$/src/main/java/SimpleWindow.java" />
99
         <option value="$PROJECT_DIR$/src/main/java/ConwayGameOfLife.java" />
107
         <option value="$PROJECT_DIR$/src/main/java/ConwayGameOfLife.java" />
100
         <option value="$PROJECT_DIR$/src/main/java/Life.java" />
108
         <option value="$PROJECT_DIR$/src/main/java/Life.java" />
101
-        <option value="$PROJECT_DIR$/src/test/java/com/zipcodeconway/ConwayGameOfLifeTest.java" />
102
         <option value="$PROJECT_DIR$/src/main/java/com/zipcodeconway/SimpleWindow.java" />
109
         <option value="$PROJECT_DIR$/src/main/java/com/zipcodeconway/SimpleWindow.java" />
103
         <option value="$PROJECT_DIR$/src/main/java/com/zipcodeconway/README.md" />
110
         <option value="$PROJECT_DIR$/src/main/java/com/zipcodeconway/README.md" />
111
+        <option value="$PROJECT_DIR$/src/test/java/com/zipcodeconway/ConwayGameOfLifeTest.java" />
104
         <option value="$PROJECT_DIR$/src/main/java/com/zipcodeconway/ConwayGameOfLife.java" />
112
         <option value="$PROJECT_DIR$/src/main/java/com/zipcodeconway/ConwayGameOfLife.java" />
105
       </list>
113
       </list>
106
     </option>
114
     </option>
111
     <detection-done>true</detection-done>
119
     <detection-done>true</detection-done>
112
     <sorting>DEFINITION_ORDER</sorting>
120
     <sorting>DEFINITION_ORDER</sorting>
113
   </component>
121
   </component>
114
-  <component name="ProjectFrameBounds" extendedState="1">
122
+  <component name="ProjectFrameBounds">
115
     <option name="y" value="23" />
123
     <option name="y" value="23" />
116
     <option name="width" value="1440" />
124
     <option name="width" value="1440" />
117
     <option name="height" value="793" />
125
     <option name="height" value="793" />
259
       <module name="Game-Of-Life-Java" />
267
       <module name="Game-Of-Life-Java" />
260
       <envs />
268
       <envs />
261
     </configuration>
269
     </configuration>
262
-    <configuration name="GameofLife" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
263
-      <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
264
-      <option name="MAIN_CLASS_NAME" value="GameofLife" />
265
-      <option name="VM_PARAMETERS" />
266
-      <option name="PROGRAM_PARAMETERS" />
267
-      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
268
-      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
269
-      <option name="ALTERNATIVE_JRE_PATH" />
270
-      <option name="ENABLE_SWING_INSPECTOR" value="false" />
271
-      <option name="ENV_VARIABLES" />
272
-      <option name="PASS_PARENT_ENVS" value="true" />
273
-      <module name="Game-Of-Life-Java" />
274
-      <envs />
275
-    </configuration>
276
     <configuration default="true" type="Application" factoryName="Application">
270
     <configuration default="true" type="Application" factoryName="Application">
277
       <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
271
       <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
278
       <option name="MAIN_CLASS_NAME" />
272
       <option name="MAIN_CLASS_NAME" />
312
       <envs />
306
       <envs />
313
       <patterns />
307
       <patterns />
314
     </configuration>
308
     </configuration>
315
-    <configuration name="ConwayGameOfLifeTest.runTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
309
+    <configuration name="ConwayGameOfLifeTest.runTest1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
316
       <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
310
       <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
317
         <pattern>
311
         <pattern>
318
           <option name="PATTERN" value="com.zipcodeconway.*" />
312
           <option name="PATTERN" value="com.zipcodeconway.*" />
324
       <option name="ALTERNATIVE_JRE_PATH" />
318
       <option name="ALTERNATIVE_JRE_PATH" />
325
       <option name="PACKAGE_NAME" value="com.zipcodeconway" />
319
       <option name="PACKAGE_NAME" value="com.zipcodeconway" />
326
       <option name="MAIN_CLASS_NAME" value="com.zipcodeconway.ConwayGameOfLifeTest" />
320
       <option name="MAIN_CLASS_NAME" value="com.zipcodeconway.ConwayGameOfLifeTest" />
327
-      <option name="METHOD_NAME" value="runTest" />
321
+      <option name="METHOD_NAME" value="runTest1" />
328
       <option name="TEST_OBJECT" value="method" />
322
       <option name="TEST_OBJECT" value="method" />
329
       <option name="VM_PARAMETERS" value="-ea" />
323
       <option name="VM_PARAMETERS" value="-ea" />
330
       <option name="PARAMETERS" />
324
       <option name="PARAMETERS" />
337
       <envs />
331
       <envs />
338
       <patterns />
332
       <patterns />
339
     </configuration>
333
     </configuration>
340
-    <configuration name="ConwayGameOfLifeTest.runTest2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
334
+    <configuration name="ConwayGameOfLifeTest.runTest3" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
341
       <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
335
       <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
342
         <pattern>
336
         <pattern>
343
           <option name="PATTERN" value="com.zipcodeconway.*" />
337
           <option name="PATTERN" value="com.zipcodeconway.*" />
349
       <option name="ALTERNATIVE_JRE_PATH" />
343
       <option name="ALTERNATIVE_JRE_PATH" />
350
       <option name="PACKAGE_NAME" value="com.zipcodeconway" />
344
       <option name="PACKAGE_NAME" value="com.zipcodeconway" />
351
       <option name="MAIN_CLASS_NAME" value="com.zipcodeconway.ConwayGameOfLifeTest" />
345
       <option name="MAIN_CLASS_NAME" value="com.zipcodeconway.ConwayGameOfLifeTest" />
352
-      <option name="METHOD_NAME" value="runTest2" />
346
+      <option name="METHOD_NAME" value="runTest3" />
347
+      <option name="TEST_OBJECT" value="method" />
348
+      <option name="VM_PARAMETERS" value="-ea" />
349
+      <option name="PARAMETERS" />
350
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
351
+      <option name="ENV_VARIABLES" />
352
+      <option name="PASS_PARENT_ENVS" value="true" />
353
+      <option name="TEST_SEARCH_SCOPE">
354
+        <value defaultName="singleModule" />
355
+      </option>
356
+      <envs />
357
+      <patterns />
358
+    </configuration>
359
+    <configuration name="ConwayGameOfLifeTest.testIsAlive2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
360
+      <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
361
+        <pattern>
362
+          <option name="PATTERN" value="com.zipcodeconway.*" />
363
+          <option name="ENABLED" value="true" />
364
+        </pattern>
365
+      </extension>
366
+      <module name="Game-Of-Life-Java" />
367
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
368
+      <option name="ALTERNATIVE_JRE_PATH" />
369
+      <option name="PACKAGE_NAME" value="com.zipcodeconway" />
370
+      <option name="MAIN_CLASS_NAME" value="com.zipcodeconway.ConwayGameOfLifeTest" />
371
+      <option name="METHOD_NAME" value="testIsAlive2" />
353
       <option name="TEST_OBJECT" value="method" />
372
       <option name="TEST_OBJECT" value="method" />
354
       <option name="VM_PARAMETERS" value="-ea" />
373
       <option name="VM_PARAMETERS" value="-ea" />
355
       <option name="PARAMETERS" />
374
       <option name="PARAMETERS" />
445
     </configuration>
464
     </configuration>
446
     <list size="6">
465
     <list size="6">
447
       <item index="0" class="java.lang.String" itemvalue="Maven.ConwayLife" />
466
       <item index="0" class="java.lang.String" itemvalue="Maven.ConwayLife" />
448
-      <item index="1" class="java.lang.String" itemvalue="Application.GameofLife" />
449
-      <item index="2" class="java.lang.String" itemvalue="Application.ConwayGameOfLife" />
450
-      <item index="3" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest" />
451
-      <item index="4" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest2" />
452
-      <item index="5" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest" />
467
+      <item index="1" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.testIsAlive2" />
468
+      <item index="2" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest" />
469
+      <item index="3" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest3" />
470
+      <item index="4" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest1" />
471
+      <item index="5" class="java.lang.String" itemvalue="Application.ConwayGameOfLife" />
453
     </list>
472
     </list>
454
     <recent_temporary>
473
     <recent_temporary>
455
       <list size="5">
474
       <list size="5">
456
         <item index="0" class="java.lang.String" itemvalue="Application.ConwayGameOfLife" />
475
         <item index="0" class="java.lang.String" itemvalue="Application.ConwayGameOfLife" />
457
         <item index="1" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest" />
476
         <item index="1" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest" />
458
-        <item index="2" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest2" />
459
-        <item index="3" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest" />
460
-        <item index="4" class="java.lang.String" itemvalue="Application.GameofLife" />
477
+        <item index="2" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest3" />
478
+        <item index="3" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest1" />
479
+        <item index="4" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.testIsAlive2" />
461
       </list>
480
       </list>
462
     </recent_temporary>
481
     </recent_temporary>
463
   </component>
482
   </component>
475
       <option name="presentableId" value="Default" />
494
       <option name="presentableId" value="Default" />
476
       <updated>1519668901598</updated>
495
       <updated>1519668901598</updated>
477
       <workItem from="1519668902904" duration="14517000" />
496
       <workItem from="1519668902904" duration="14517000" />
478
-      <workItem from="1520801916382" duration="6653000" />
497
+      <workItem from="1520801916382" duration="33053000" />
479
     </task>
498
     </task>
480
     <servers />
499
     <servers />
481
   </component>
500
   </component>
482
   <component name="TestHistory">
501
   <component name="TestHistory">
483
-    <history-entry file="ConwayGameOfLifeTest - 2018.02.26 at 16h 03m 01s.xml">
502
+    <history-entry file="ConwayGameOfLifeTest - 2018.03.12 at 19h 41m 47s.xml">
484
       <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
503
       <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
485
     </history-entry>
504
     </history-entry>
486
-    <history-entry file="ConwayGameOfLifeTest - 2018.02.26 at 16h 05m 07s.xml">
505
+    <history-entry file="ConwayGameOfLifeTest - 2018.03.12 at 19h 43m 58s.xml">
487
       <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
506
       <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
488
     </history-entry>
507
     </history-entry>
489
-    <history-entry file="ConwayGameOfLifeTest - 2018.02.26 at 16h 06m 11s.xml">
508
+    <history-entry file="ConwayGameOfLifeTest - 2018.03.12 at 20h 24m 50s.xml">
490
       <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
509
       <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
491
     </history-entry>
510
     </history-entry>
492
-    <history-entry file="ConwayGameOfLifeTest - 2018.03.11 at 16h 59m 05s.xml">
493
-      <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
511
+    <history-entry file="ConwayGameOfLifeTest_runTest1 - 2018.03.12 at 19h 37m 26s.xml">
512
+      <configuration name="ConwayGameOfLifeTest.runTest1" configurationId="JUnit" />
494
     </history-entry>
513
     </history-entry>
495
-    <history-entry file="ConwayGameOfLifeTest - 2018.03.11 at 17h 23m 11s.xml">
496
-      <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
514
+    <history-entry file="ConwayGameOfLifeTest_runTest1 - 2018.03.12 at 19h 39m 16s.xml">
515
+      <configuration name="ConwayGameOfLifeTest.runTest1" configurationId="JUnit" />
497
     </history-entry>
516
     </history-entry>
498
-    <history-entry file="ConwayGameOfLifeTest - 2018.03.11 at 17h 25m 50s.xml">
499
-      <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
517
+    <history-entry file="ConwayGameOfLifeTest_runTest1 - 2018.03.12 at 19h 39m 37s.xml">
518
+      <configuration name="ConwayGameOfLifeTest.runTest1" configurationId="JUnit" />
500
     </history-entry>
519
     </history-entry>
501
-    <history-entry file="ConwayGameOfLifeTest - 2018.03.11 at 17h 26m 15s.xml">
502
-      <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
520
+    <history-entry file="ConwayGameOfLifeTest_runTest1 - 2018.03.12 at 19h 39m 39s.xml">
521
+      <configuration name="ConwayGameOfLifeTest.runTest1" configurationId="JUnit" />
503
     </history-entry>
522
     </history-entry>
504
-    <history-entry file="ConwayGameOfLifeTest_runTest - 2018.02.26 at 15h 41m 14s.xml">
505
-      <configuration name="ConwayGameOfLifeTest.runTest" configurationId="JUnit" />
523
+    <history-entry file="ConwayGameOfLifeTest_runTest1 - 2018.03.12 at 19h 39m 46s.xml">
524
+      <configuration name="ConwayGameOfLifeTest.runTest1" configurationId="JUnit" />
506
     </history-entry>
525
     </history-entry>
507
-    <history-entry file="ConwayGameOfLifeTest_runTest2 - 2018.02.26 at 15h 42m 02s.xml">
508
-      <configuration name="ConwayGameOfLifeTest.runTest2" configurationId="JUnit" />
526
+    <history-entry file="ConwayGameOfLifeTest_runTest3 - 2018.03.12 at 19h 42m 29s.xml">
527
+      <configuration name="ConwayGameOfLifeTest.runTest3" configurationId="JUnit" />
509
     </history-entry>
528
     </history-entry>
510
-    <history-entry file="ConwayGameOfLifeTest_runTest2 - 2018.02.26 at 15h 42m 18s.xml">
511
-      <configuration name="ConwayGameOfLifeTest.runTest2" configurationId="JUnit" />
529
+    <history-entry file="ConwayGameOfLifeTest_runTest3 - 2018.03.12 at 19h 42m 39s.xml">
530
+      <configuration name="ConwayGameOfLifeTest.runTest3" configurationId="JUnit" />
512
     </history-entry>
531
     </history-entry>
513
   </component>
532
   </component>
514
   <component name="TimeTrackingManager">
533
   <component name="TimeTrackingManager">
515
-    <option name="totallyTimeSpent" value="21170000" />
534
+    <option name="totallyTimeSpent" value="47570000" />
516
   </component>
535
   </component>
517
   <component name="ToolWindowManager">
536
   <component name="ToolWindowManager">
518
-    <frame x="0" y="23" width="1440" height="793" extended-state="1" />
537
+    <frame x="0" y="23" width="1440" height="793" extended-state="0" />
519
     <editor active="true" />
538
     <editor active="true" />
520
     <layout>
539
     <layout>
521
       <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
540
       <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
522
       <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
541
       <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
523
-      <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32833788" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
542
+      <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32808024" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
524
       <window_info id="Palette&#9;" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
543
       <window_info id="Palette&#9;" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
525
       <window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
544
       <window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
526
       <window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
545
       <window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
527
       <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
546
       <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
528
       <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
547
       <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
529
-      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.46848136" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
548
+      <window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.11318052" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
530
       <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
549
       <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
531
-      <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32970026" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
550
+      <window_info id="Coverage" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297568" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
551
+      <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.2284012" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
532
       <window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
552
       <window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
533
       <window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
553
       <window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
534
-      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2532189" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
554
+      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.18025751" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
535
       <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
555
       <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
536
       <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
556
       <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
537
       <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
557
       <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
538
       <window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
558
       <window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
539
       <window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
559
       <window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
540
-      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
560
+      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3982808" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
541
       <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
561
       <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
542
       <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
562
       <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
543
       <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
563
       <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
555
   </component>
575
   </component>
556
   <component name="XDebuggerManager">
576
   <component name="XDebuggerManager">
557
     <breakpoint-manager>
577
     <breakpoint-manager>
558
-      <option name="time" value="2" />
578
+      <option name="time" value="25" />
559
     </breakpoint-manager>
579
     </breakpoint-manager>
560
     <watches-manager />
580
     <watches-manager />
561
   </component>
581
   </component>
574
       <provider selected="true" editor-type-id="text-editor">
594
       <provider selected="true" editor-type-id="text-editor">
575
         <state relative-caret-position="300">
595
         <state relative-caret-position="300">
576
           <caret line="20" column="0" lean-forward="false" selection-start-line="20" selection-start-column="0" selection-end-line="20" selection-end-column="0" />
596
           <caret line="20" column="0" lean-forward="false" selection-start-line="20" selection-start-column="0" selection-end-line="20" selection-end-column="0" />
577
-          <folding>
578
-            <element signature="e#269#270#0" expanded="true" />
579
-            <element signature="e#334#335#0" expanded="true" />
580
-            <element signature="e#1252#1253#0" expanded="true" />
581
-            <element signature="e#1288#1289#0" expanded="true" />
582
-          </folding>
597
+          <folding />
583
         </state>
598
         </state>
584
       </provider>
599
       </provider>
585
     </entry>
600
     </entry>
626
     <entry file="file://$USER_HOME$/Downloads/ConwayLifeRandomat50.png" />
641
     <entry file="file://$USER_HOME$/Downloads/ConwayLifeRandomat50.png" />
627
     <entry file="file://$USER_HOME$/Documents/gitea/gitea/custom/public/img/ConwayLifeUML.png" />
642
     <entry file="file://$USER_HOME$/Documents/gitea/gitea/custom/public/img/ConwayLifeUML.png" />
628
     <entry file="file://$PROJECT_DIR$/src/main/java/GameofLife.java" />
643
     <entry file="file://$PROJECT_DIR$/src/main/java/GameofLife.java" />
629
-    <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodeconway/ConwayGameOfLifeTest.java">
644
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodeconway/SimpleWindow.java">
630
       <provider selected="true" editor-type-id="text-editor">
645
       <provider selected="true" editor-type-id="text-editor">
631
-        <state relative-caret-position="450">
632
-          <caret line="32" column="32" lean-forward="false" selection-start-line="32" selection-start-column="32" selection-end-line="32" selection-end-column="32" />
633
-          <folding />
646
+        <state relative-caret-position="255">
647
+          <caret line="17" column="42" lean-forward="false" selection-start-line="17" selection-start-column="42" selection-end-line="17" selection-end-column="42" />
648
+          <folding>
649
+            <element signature="imports" expanded="true" />
650
+          </folding>
634
         </state>
651
         </state>
635
       </provider>
652
       </provider>
636
     </entry>
653
     </entry>
639
         <state />
656
         <state />
640
       </provider>
657
       </provider>
641
     </entry>
658
     </entry>
642
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodeconway/SimpleWindow.java">
659
+    <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/rt.jar!/sun/reflect/NativeMethodAccessorImpl.class">
643
       <provider selected="true" editor-type-id="text-editor">
660
       <provider selected="true" editor-type-id="text-editor">
644
-        <state relative-caret-position="255">
645
-          <caret line="17" column="42" lean-forward="false" selection-start-line="17" selection-start-column="42" selection-end-line="17" selection-end-column="42" />
646
-          <folding>
647
-            <element signature="imports" expanded="true" />
648
-          </folding>
661
+        <state relative-caret-position="313">
662
+          <caret line="33" column="33" lean-forward="false" selection-start-line="33" selection-start-column="33" selection-end-line="33" selection-end-column="33" />
663
+          <folding />
664
+        </state>
665
+      </provider>
666
+    </entry>
667
+    <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodeconway/ConwayGameOfLifeTest.java">
668
+      <provider selected="true" editor-type-id="text-editor">
669
+        <state relative-caret-position="855">
670
+          <caret line="60" column="0" lean-forward="false" selection-start-line="60" selection-start-column="0" selection-end-line="60" selection-end-column="0" />
671
+          <folding />
649
         </state>
672
         </state>
650
       </provider>
673
       </provider>
651
     </entry>
674
     </entry>
652
     <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodeconway/ConwayGameOfLife.java">
675
     <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodeconway/ConwayGameOfLife.java">
653
       <provider selected="true" editor-type-id="text-editor">
676
       <provider selected="true" editor-type-id="text-editor">
654
-        <state relative-caret-position="214">
655
-          <caret line="68" column="4" lean-forward="false" selection-start-line="68" selection-start-column="4" selection-end-line="68" selection-end-column="4" />
656
-          <folding>
657
-            <element signature="e#269#270#0" expanded="true" />
658
-            <element signature="e#334#335#0" expanded="true" />
659
-            <element signature="e#1252#1253#0" expanded="true" />
660
-            <element signature="e#1288#1289#0" expanded="true" />
661
-          </folding>
677
+        <state relative-caret-position="759">
678
+          <caret line="55" column="9" lean-forward="true" selection-start-line="55" selection-start-column="9" selection-end-line="55" selection-end-column="9" />
679
+          <folding />
662
         </state>
680
         </state>
663
       </provider>
681
       </provider>
664
     </entry>
682
     </entry>

+ 95
- 46
src/main/java/com/zipcodeconway/ConwayGameOfLife.java View File

1
 package com.zipcodeconway;
1
 package com.zipcodeconway;
2
 
2
 
3
+import java.util.Arrays;
4
+
3
 public class ConwayGameOfLife {
5
 public class ConwayGameOfLife {
4
     private Integer dimension;
6
     private Integer dimension;
5
-    private int[][] generation;
7
+    private int[][] current;
8
+    //private int[][] next;
6
     public int neighbourRow;
9
     public int neighbourRow;
7
     public int neighbourCol;
10
     public int neighbourCol;
8
     private SimpleWindow displayWindow;
11
     private SimpleWindow displayWindow;
9
 
12
 
10
     public ConwayGameOfLife(Integer dimension) {
13
     public ConwayGameOfLife(Integer dimension) {
11
         this.displayWindow = new SimpleWindow(dimension);
14
         this.displayWindow = new SimpleWindow(dimension);
12
-     }
15
+        this.current = createRandomStart(dimension);
16
+        //this.next = new int[dimension][dimension];
17
+    }
13
 
18
 
14
     public ConwayGameOfLife(Integer dimension, int[][] startmatrix) {
19
     public ConwayGameOfLife(Integer dimension, int[][] startmatrix) {
15
         this.displayWindow = new SimpleWindow(dimension);
20
         this.displayWindow = new SimpleWindow(dimension);
16
-        this.generation = startmatrix;
21
+        this.current = startmatrix;
22
+        this.dimension = dimension;
23
+        //this.next = new int[dimension][dimension];
17
     }
24
     }
18
 
25
 
19
     public static void main(String[] args) {
26
     public static void main(String[] args) {
25
     // Which cells are alive or dead in generation 0.
32
     // Which cells are alive or dead in generation 0.
26
     // allocates and returns the starting matrix of size 'dimension'
33
     // allocates and returns the starting matrix of size 'dimension'
27
     private int[][] createRandomStart(Integer dimension) {
34
     private int[][] createRandomStart(Integer dimension) {
28
-        int[][]start = new int[dimension][dimension];
29
-        for(int row =0;row<dimension;row++){
30
-            for(int col=0;col<dimension;col++){
35
+        int[][] start = new int[dimension][dimension];
36
+        for (int row = 0; row < dimension; row++) {
37
+            for (int col = 0; col < dimension; col++) {
31
                 int val = (int) Math.round(Math.random());
38
                 int val = (int) Math.round(Math.random());
32
-                start[row][col]=val;
39
+                start[row][col] = val;
33
             }
40
             }
34
         }
41
         }
35
-
36
         return start;
42
         return start;
37
     }
43
     }
38
 
44
 
39
     public int[][] simulate(Integer maxGenerations) {
45
     public int[][] simulate(Integer maxGenerations) {
40
-        return new int[1][1];
46
+        int[][] currentWorld = current;
47
+        int[][] nextWorld = new int[dimension][dimension];
48
+
49
+        for (int i = 0; i <= maxGenerations; i++) {
50
+            this.displayWindow.display(currentWorld, i);
51
+
52
+
53
+            nextWorld = runSim(currentWorld, nextWorld); // tested!!!
54
+
55
+            currentWorld = copyAndZeroOut(nextWorld, currentWorld);
56
+        }
57
+        this.displayWindow.sleep(125);
58
+        //displayWindow.sleep(10000);
59
+        return currentWorld;
60
+    }
61
+
62
+    private int[][] runSim(int[][] currentWorld, int[][] nextWorld) {
63
+        for (int row = 0; row < currentWorld.length; row++) {
64
+            for (int col = 0; col < currentWorld[row].length; col++) {
65
+                nextWorld[row][col] = isAlive(row, col, currentWorld);
66
+            }
67
+        }
68
+        return nextWorld;
41
     }
69
     }
42
 
70
 
43
     // copy the values of 'next' matrix to 'current' matrix,
71
     // copy the values of 'next' matrix to 'current' matrix,
44
     // and then zero out the contents of 'next' matrix
72
     // and then zero out the contents of 'next' matrix
45
-    public void copyAndZeroOut(int [][] next, int[][] current) {
73
+    public int[][] copyAndZeroOut(int[][] nextWorld, int[][] currentWorld) {
74
+        for (int i = 0; i < currentWorld.length; i++) {
75
+            System.arraycopy(nextWorld[i], 0, currentWorld[i], 0, currentWorld.length);
76
+            Arrays.fill(nextWorld[i], 0);
77
+        }
78
+        return currentWorld;
46
     }
79
     }
47
 
80
 
48
     // Calculate if an individual cell should be alive in the next generation.
81
     // Calculate if an individual cell should be alive in the next generation.
53
 		Any live cell with two or three live neighbours lives, unchanged, to the next generation.
86
 		Any live cell with two or three live neighbours lives, unchanged, to the next generation.
54
 		Any dead cell with exactly three live neighbours cells will come to life.
87
 		Any dead cell with exactly three live neighbours cells will come to life.
55
 	*/
88
 	*/
56
-    private int isAlive(int row, int col, int[][] world) {
57
-        int[]neighbours = getNeignbours(row,col,world);
58
-        if(world[row][col]==1 && getNumberOfLiveNeighbours(neighbours)<2){ world[row][col]=0; }
59
-        else if(world[row][col]==1 && getNumberOfLiveNeighbours(neighbours)>3){world[row][col]=0; }
60
-        else if(world[row][col]==1 && (getNumberOfLiveNeighbours(neighbours)==3)||(getNumberOfLiveNeighbours(neighbours)==2)){world[row][col]=1; }
61
-        else if (world[row][col]==0&& getNumberOfLiveNeighbours(neighbours)==3){world[row][col]=1}
89
+    public int isAlive(int row, int col, int[][] world) {
90
+        int neighbours = getNeighbours(row, col, world);
62
 
91
 
92
+        //test
93
+        if (neighbours == 2)
94
+            return world[row][col];
95
+        else if (neighbours == 3)
96
+            return 1;
97
+        else
98
+            return 0;
99
+        //
100
+
101
+//        if (world[row][col] == 1 && (neighbours < 2)) {
102
+//            return 0;
103
+//        } else if (world[row][col] == 1 && (neighbours > 3)) {
104
+//             return 0;
105
+//        } else if (world[row][col] == 1 && (neighbours == 3) ||
106
+//                (neighbours == 2)) {
107
+//            return 1;
108
+//        } else if (world[row][col] == 0 && (neighbours == 3)) {
109
+//            return 1;
110
+//        }
63
 
111
 
64
-        return world[row][col];
65
-    }
66
-    public int[] getNeignbours(int row, int col,int[][]input){
67
-        int[] neignbours = new int[8];
68
-        for(int i=0;i<8;i++){
69
-            checkBoundries(row,col,input);
70
-            neignbours[i]=input[neighbourRow][neighbourCol];
71
-        }
72
-        return neignbours;
73
     }
112
     }
74
-    public int getNumberOfLiveNeighbours(int[]neighbours){
75
-        int count=0;
76
-        for(int i=0;i<neighbours.length;i++){
77
-            count+=neighbours[i];
113
+
114
+    public int getNeighbours(int row, int col, int[][] input) {
115
+        int totalNeighbors = 0;
116
+        int index = 0;
117
+        for (int i = -1; i <= 1; i++) {
118
+            for (int j = -1; j <= 1; j++) {
119
+                int neighbourRow = getNeighbourRow(i, row, input);
120
+                int neighbourCol = getNeighbourCol(j, col, input);
121
+                if (!(getNeighbourRow(i, row, input) == row && getNeighbourCol(j, col, input) == col)) {
122
+                    totalNeighbors += input[neighbourRow][neighbourCol];
123
+                    index++;
124
+                }
125
+            }
78
         }
126
         }
79
-        return count;
127
+        return totalNeighbors;
80
     }
128
     }
81
-    public void checkBoundries(int row, int col,int[][]input) {
82
-        if (row - 1 < 0) {
83
-            neighbourRow = input.length;
84
-        } else {
85
-            neighbourRow = row - 1;
86
-        }
87
-        if (row + 1 > input.length) {
129
+
130
+    public int getNeighbourRow(int x, int row, int[][] input) {
131
+        int neighbourRow;
132
+        if (row + x < 0) {
133
+            neighbourRow = input.length - 1;
134
+        } else if (row + x > input.length - 1) {
88
             neighbourRow = 0;
135
             neighbourRow = 0;
89
         } else {
136
         } else {
90
-            neighbourRow = row + 1;
91
-        }
92
-        if (col - 1 < 0) {
93
-            neighbourCol = input[0].length;
94
-        } else {
95
-            neighbourCol = col - 1;
137
+            neighbourRow = row + x;
96
         }
138
         }
97
-        if (col + 1 > input[0].length) {
139
+        return neighbourRow;
140
+    }
141
+
142
+    public int getNeighbourCol(int x, int col, int[][] input) {
143
+        int neighbourCol;
144
+        if (col + x < 0) {
145
+            neighbourCol = input[0].length - 1;
146
+        } else if (col + x > input[0].length - 1) {
98
             neighbourCol = 0;
147
             neighbourCol = 0;
99
         } else {
148
         } else {
100
-            neighbourCol = col + 1;
149
+            neighbourCol = col + x;
101
         }
150
         }
151
+        return neighbourCol;
102
     }
152
     }
103
-
104
 }
153
 }

+ 54
- 0
src/test/java/com/zipcodeconway/ConwayGameOfLifeTest.java View File

1
 package com.zipcodeconway;
1
 package com.zipcodeconway;
2
 
2
 
3
+import org.junit.Assert;
3
 import org.junit.Test;
4
 import org.junit.Test;
4
 
5
 
5
 import static org.junit.Assert.*;
6
 import static org.junit.Assert.*;
6
 
7
 
7
 public class ConwayGameOfLifeTest {
8
 public class ConwayGameOfLifeTest {
9
+    @Test
10
+    public void testIsAlive1(){
11
+        ConwayGameOfLife x=new ConwayGameOfLife(5);
12
+        int[][] start = {
13
+                {0, 0, 0, 0, 0},
14
+                {0, 0, 1, 0, 0},
15
+                {0, 0, 1, 0, 0},
16
+                {0, 0, 1, 0, 0},
17
+                {0, 0, 0, 0, 0}};
18
+        int expected =1;
19
+        int actual = x.isAlive(2,1,start);
20
+        Assert.assertEquals(expected,actual);
21
+    }
22
+    @Test
23
+    public void testIsAlive2(){
24
+        ConwayGameOfLife x=new ConwayGameOfLife(5);
25
+        int[][] start = {
26
+                {0, 0, 0, 0, 0},
27
+                {0, 0, 1, 0, 0},
28
+                {0, 0, 1, 0, 0},
29
+                {0, 0, 1, 0, 0},
30
+                {0, 0, 0, 0, 0}};
31
+        int expected =1;
32
+        int actual = x.isAlive(2,2,start);
33
+        Assert.assertEquals(expected,actual);
34
+    }
35
+    @Test
36
+    public void testNumberOfLiveGetNeignbours(){
37
+        ConwayGameOfLife x=new ConwayGameOfLife(5);
38
+        int[][] start = {
39
+                {0, 0, 0, 0, 0},
40
+                {0, 0, 1, 0, 0},
41
+                {0, 0, 1, 0, 0},
42
+                {0, 0, 1, 0, 0},
43
+                {0, 0, 0, 0, 0}};
44
+        int expected =2;
45
+        //int actual = x.getneighbours(x.getNeighbours(3,3,start));
46
+        //Assert.assertEquals(expected,actual);
47
+    }
48
+    @Test
49
+    public void testGetNeignbours(){
50
+        ConwayGameOfLife x=new ConwayGameOfLife(5);
51
+        int[][] start = {
52
+                {0, 0, 0, 0, 0},
53
+                {0, 0, 1, 0, 0},
54
+                {0, 0, 1, 0, 0},
55
+                {0, 0, 1, 0, 0},
56
+                {0, 0, 0, 0, 0}};
57
+        int expected =1;
58
+        //int actual = x.getNeighbours(1,1,start)[7];
59
+        //Assert.assertEquals(expected,actual);
60
+    }
8
 
61
 
9
     @Test
62
     @Test
10
     public void runTest1() {
63
     public void runTest1() {
22
                 {0, 0, 0, 0, 0}};
75
                 {0, 0, 0, 0, 0}};
23
         ConwayGameOfLife sim = new ConwayGameOfLife(5, start);
76
         ConwayGameOfLife sim = new ConwayGameOfLife(5, start);
24
         int[][] results = sim.simulate(9);
77
         int[][] results = sim.simulate(9);
78
+
25
         assertTrue(java.util.Arrays.deepEquals(results, expected));
79
         assertTrue(java.util.Arrays.deepEquals(results, expected));
26
     }
80
     }
27
 
81