Jessica Campbell 6 年 前
コミット
e203419790
共有2 個のファイルを変更した140 個の追加101 個の削除を含む
  1. 65
    70
      .idea/workspace.xml
  2. 75
    31
      src/main/java/com/zipcodeconway/ConwayGameOfLife.java

+ 65
- 70
.idea/workspace.xml ファイルの表示

@@ -2,7 +2,6 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 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 5
       <change beforePath="$PROJECT_DIR$/src/main/java/com/zipcodeconway/ConwayGameOfLife.java" afterPath="$PROJECT_DIR$/src/main/java/com/zipcodeconway/ConwayGameOfLife.java" />
7 6
     </list>
8 7
     <ignored path="$PROJECT_DIR$/target/" />
@@ -14,7 +13,7 @@
14 13
     <option name="LAST_RESOLUTION" value="IGNORE" />
15 14
   </component>
16 15
   <component name="FileEditorManager">
17
-    <splitter split-orientation="horizontal" split-proportion="0.81826484">
16
+    <splitter split-orientation="horizontal" split-proportion="0.6187399">
18 17
       <split-first>
19 18
         <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
20 19
           <file leaf-file-name="SimpleWindow.java" pinned="false" current-in-tab="false">
@@ -32,14 +31,9 @@
32 31
           <file leaf-file-name="ConwayGameOfLife.java" pinned="false" current-in-tab="true">
33 32
             <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodeconway/ConwayGameOfLife.java">
34 33
               <provider selected="true" editor-type-id="text-editor">
35
-                <state relative-caret-position="710">
36
-                  <caret line="66" column="30" lean-forward="true" selection-start-line="66" selection-start-column="30" selection-end-line="66" selection-end-column="30" />
37
-                  <folding>
38
-                    <element signature="e#906#907#0" expanded="true" />
39
-                    <element signature="e#942#943#0" expanded="true" />
40
-                    <element signature="e#997#998#0" expanded="true" />
41
-                    <element signature="e#1033#1034#0" expanded="true" />
42
-                  </folding>
34
+                <state relative-caret-position="360">
35
+                  <caret line="24" column="0" lean-forward="true" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" />
36
+                  <folding />
43 37
                 </state>
44 38
               </provider>
45 39
             </entry>
@@ -51,8 +45,8 @@
51 45
           <file leaf-file-name="ConwayGameOfLifeTest.java" pinned="false" current-in-tab="true">
52 46
             <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodeconway/ConwayGameOfLifeTest.java">
53 47
               <provider selected="true" editor-type-id="text-editor">
54
-                <state relative-caret-position="360">
55
-                  <caret line="26" column="0" lean-forward="false" selection-start-line="26" selection-start-column="0" selection-end-line="26" selection-end-column="0" />
48
+                <state relative-caret-position="330">
49
+                  <caret line="24" column="0" lean-forward="false" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" />
56 50
                   <folding />
57 51
                 </state>
58 52
               </provider>
@@ -250,7 +244,7 @@
250 244
       </list>
251 245
     </option>
252 246
   </component>
253
-  <component name="RunManager" selected="JUnit.ConwayGameOfLifeTest">
247
+  <component name="RunManager" selected="Application.ConwayGameOfLife">
254 248
     <configuration default="true" type="Applet" factoryName="Applet">
255 249
       <option name="HTML_USED" value="false" />
256 250
       <option name="WIDTH" value="400" />
@@ -277,20 +271,6 @@
277 271
       <module name="Game-Of-Life-Java" />
278 272
       <envs />
279 273
     </configuration>
280
-    <configuration name="GameofLife" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
281
-      <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
282
-      <option name="MAIN_CLASS_NAME" value="GameofLife" />
283
-      <option name="VM_PARAMETERS" />
284
-      <option name="PROGRAM_PARAMETERS" />
285
-      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
286
-      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
287
-      <option name="ALTERNATIVE_JRE_PATH" />
288
-      <option name="ENABLE_SWING_INSPECTOR" value="false" />
289
-      <option name="ENV_VARIABLES" />
290
-      <option name="PASS_PARENT_ENVS" value="true" />
291
-      <module name="Game-Of-Life-Java" />
292
-      <envs />
293
-    </configuration>
294 274
     <configuration default="true" type="Application" factoryName="Application">
295 275
       <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
296 276
       <option name="MAIN_CLASS_NAME" />
@@ -355,6 +335,31 @@
355 335
       <envs />
356 336
       <patterns />
357 337
     </configuration>
338
+    <configuration name="ConwayGameOfLifeTest.runTest1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
339
+      <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
340
+        <pattern>
341
+          <option name="PATTERN" value="com.zipcodeconway.*" />
342
+          <option name="ENABLED" value="true" />
343
+        </pattern>
344
+      </extension>
345
+      <module name="Game-Of-Life-Java" />
346
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
347
+      <option name="ALTERNATIVE_JRE_PATH" />
348
+      <option name="PACKAGE_NAME" value="com.zipcodeconway" />
349
+      <option name="MAIN_CLASS_NAME" value="com.zipcodeconway.ConwayGameOfLifeTest" />
350
+      <option name="METHOD_NAME" value="runTest1" />
351
+      <option name="TEST_OBJECT" value="method" />
352
+      <option name="VM_PARAMETERS" value="-ea" />
353
+      <option name="PARAMETERS" />
354
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
355
+      <option name="ENV_VARIABLES" />
356
+      <option name="PASS_PARENT_ENVS" value="true" />
357
+      <option name="TEST_SEARCH_SCOPE">
358
+        <value defaultName="singleModule" />
359
+      </option>
360
+      <envs />
361
+      <patterns />
362
+    </configuration>
358 363
     <configuration name="ConwayGameOfLifeTest.runTest2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
359 364
       <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
360 365
         <pattern>
@@ -463,19 +468,19 @@
463 468
     </configuration>
464 469
     <list size="6">
465 470
       <item index="0" class="java.lang.String" itemvalue="Maven.ConwayLife" />
466
-      <item index="1" class="java.lang.String" itemvalue="Application.GameofLife" />
467
-      <item index="2" class="java.lang.String" itemvalue="Application.ConwayGameOfLife" />
468
-      <item index="3" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest" />
469
-      <item index="4" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest2" />
470
-      <item index="5" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest" />
471
+      <item index="1" class="java.lang.String" itemvalue="Application.ConwayGameOfLife" />
472
+      <item index="2" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest" />
473
+      <item index="3" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest2" />
474
+      <item index="4" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest" />
475
+      <item index="5" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest1" />
471 476
     </list>
472 477
     <recent_temporary>
473 478
       <list size="5">
474
-        <item index="0" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest" />
475
-        <item index="1" class="java.lang.String" itemvalue="Application.ConwayGameOfLife" />
476
-        <item index="2" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest2" />
477
-        <item index="3" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest" />
478
-        <item index="4" class="java.lang.String" itemvalue="Application.GameofLife" />
479
+        <item index="0" class="java.lang.String" itemvalue="Application.ConwayGameOfLife" />
480
+        <item index="1" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest1" />
481
+        <item index="2" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest" />
482
+        <item index="3" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest2" />
483
+        <item index="4" class="java.lang.String" itemvalue="JUnit.ConwayGameOfLifeTest.runTest" />
479 484
       </list>
480 485
     </recent_temporary>
481 486
   </component>
@@ -493,44 +498,44 @@
493 498
       <option name="presentableId" value="Default" />
494 499
       <updated>1519668901598</updated>
495 500
       <workItem from="1519668902904" duration="14517000" />
496
-      <workItem from="1520878020643" duration="8732000" />
501
+      <workItem from="1520878020643" duration="14894000" />
497 502
     </task>
498 503
     <servers />
499 504
   </component>
500 505
   <component name="TestHistory">
501
-    <history-entry file="ConwayGameOfLifeTest - 2018.02.26 at 15h 45m 01s.xml">
506
+    <history-entry file="ConwayGameOfLifeTest - 2018.03.12 at 19h 49m 15s.xml">
502 507
       <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
503 508
     </history-entry>
504
-    <history-entry file="ConwayGameOfLifeTest - 2018.02.26 at 15h 59m 00s.xml">
509
+    <history-entry file="ConwayGameOfLifeTest - 2018.03.12 at 19h 51m 07s.xml">
505 510
       <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
506 511
     </history-entry>
507
-    <history-entry file="ConwayGameOfLifeTest - 2018.02.26 at 16h 02m 03s.xml">
512
+    <history-entry file="ConwayGameOfLifeTest - 2018.03.12 at 19h 52m 06s.xml">
508 513
       <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
509 514
     </history-entry>
510
-    <history-entry file="ConwayGameOfLifeTest - 2018.02.26 at 16h 03m 01s.xml">
515
+    <history-entry file="ConwayGameOfLifeTest - 2018.03.12 at 19h 55m 16s.xml">
511 516
       <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
512 517
     </history-entry>
513
-    <history-entry file="ConwayGameOfLifeTest - 2018.02.26 at 16h 05m 07s.xml">
518
+    <history-entry file="ConwayGameOfLifeTest - 2018.03.12 at 19h 57m 18s.xml">
514 519
       <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
515 520
     </history-entry>
516
-    <history-entry file="ConwayGameOfLifeTest - 2018.02.26 at 16h 06m 11s.xml">
521
+    <history-entry file="ConwayGameOfLifeTest - 2018.03.12 at 20h 04m 42s.xml">
517 522
       <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
518 523
     </history-entry>
519
-    <history-entry file="ConwayGameOfLifeTest - 2018.03.12 at 14h 51m 42s.xml">
524
+    <history-entry file="ConwayGameOfLifeTest - 2018.03.12 at 20h 09m 48s.xml">
520 525
       <configuration name="ConwayGameOfLifeTest" configurationId="JUnit" />
521 526
     </history-entry>
522
-    <history-entry file="ConwayGameOfLifeTest_runTest - 2018.02.26 at 15h 41m 14s.xml">
523
-      <configuration name="ConwayGameOfLifeTest.runTest" configurationId="JUnit" />
527
+    <history-entry file="ConwayGameOfLifeTest_runTest1 - 2018.03.12 at 20h 14m 36s.xml">
528
+      <configuration name="ConwayGameOfLifeTest.runTest1" configurationId="JUnit" />
524 529
     </history-entry>
525
-    <history-entry file="ConwayGameOfLifeTest_runTest2 - 2018.02.26 at 15h 42m 02s.xml">
526
-      <configuration name="ConwayGameOfLifeTest.runTest2" configurationId="JUnit" />
530
+    <history-entry file="ConwayGameOfLifeTest_runTest1 - 2018.03.12 at 20h 18m 22s.xml">
531
+      <configuration name="ConwayGameOfLifeTest.runTest1" configurationId="JUnit" />
527 532
     </history-entry>
528
-    <history-entry file="ConwayGameOfLifeTest_runTest2 - 2018.02.26 at 15h 42m 18s.xml">
529
-      <configuration name="ConwayGameOfLifeTest.runTest2" configurationId="JUnit" />
533
+    <history-entry file="ConwayGameOfLifeTest_runTest1 - 2018.03.12 at 20h 20m 40s.xml">
534
+      <configuration name="ConwayGameOfLifeTest.runTest1" configurationId="JUnit" />
530 535
     </history-entry>
531 536
   </component>
532 537
   <component name="TimeTrackingManager">
533
-    <option name="totallyTimeSpent" value="23249000" />
538
+    <option name="totallyTimeSpent" value="29411000" />
534 539
   </component>
535 540
   <component name="ToolWindowManager">
536 541
     <frame x="0" y="0" width="1280" height="800" extended-state="0" />
@@ -544,12 +549,12 @@
544 549
       <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 550
       <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 551
       <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="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.15405777" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
552
+      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.16781293" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
548 553
       <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 554
       <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 555
       <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" />
551 556
       <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" />
552
-      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.11470113" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
557
+      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.0" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
553 558
       <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" />
554 559
       <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" />
555 560
       <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" />
@@ -592,12 +597,7 @@
592 597
       <provider selected="true" editor-type-id="text-editor">
593 598
         <state relative-caret-position="300">
594 599
           <caret line="20" column="0" lean-forward="false" selection-start-line="20" selection-start-column="0" selection-end-line="20" selection-end-column="0" />
595
-          <folding>
596
-            <element signature="e#906#907#0" expanded="true" />
597
-            <element signature="e#942#943#0" expanded="true" />
598
-            <element signature="e#997#998#0" expanded="true" />
599
-            <element signature="e#1033#1034#0" expanded="true" />
600
-          </folding>
600
+          <folding />
601 601
         </state>
602 602
       </provider>
603 603
     </entry>
@@ -656,22 +656,17 @@
656 656
     </entry>
657 657
     <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodeconway/ConwayGameOfLifeTest.java">
658 658
       <provider selected="true" editor-type-id="text-editor">
659
-        <state relative-caret-position="360">
660
-          <caret line="26" column="0" lean-forward="false" selection-start-line="26" selection-start-column="0" selection-end-line="26" selection-end-column="0" />
659
+        <state relative-caret-position="330">
660
+          <caret line="24" column="0" lean-forward="false" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" />
661 661
           <folding />
662 662
         </state>
663 663
       </provider>
664 664
     </entry>
665 665
     <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodeconway/ConwayGameOfLife.java">
666 666
       <provider selected="true" editor-type-id="text-editor">
667
-        <state relative-caret-position="710">
668
-          <caret line="66" column="30" lean-forward="true" selection-start-line="66" selection-start-column="30" selection-end-line="66" selection-end-column="30" />
669
-          <folding>
670
-            <element signature="e#906#907#0" expanded="true" />
671
-            <element signature="e#942#943#0" expanded="true" />
672
-            <element signature="e#997#998#0" expanded="true" />
673
-            <element signature="e#1033#1034#0" expanded="true" />
674
-          </folding>
667
+        <state relative-caret-position="360">
668
+          <caret line="24" column="0" lean-forward="true" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" />
669
+          <folding />
675 670
         </state>
676 671
       </provider>
677 672
     </entry>

+ 75
- 31
src/main/java/com/zipcodeconway/ConwayGameOfLife.java ファイルの表示

@@ -2,18 +2,20 @@ package com.zipcodeconway;
2 2
 
3 3
 public class ConwayGameOfLife {
4 4
 
5
-    private int [][] currentGen;
6
-    private int [][] nextGen;
5
+    private int[][] currentGen;
6
+    private int[][] nextGen;
7 7
     private SimpleWindow displayWindow;
8 8
 
9 9
     public ConwayGameOfLife(Integer dimension) {
10
-        currentGen = createRandomStart(dimension);
11
-        nextGen = new int[dimension][dimension];
10
+        this.currentGen = createRandomStart(dimension);
11
+        this.nextGen = new int[dimension][dimension];
12 12
         this.displayWindow = new SimpleWindow(dimension);
13
-     }
13
+    }
14 14
 
15
-    public ConwayGameOfLife(Integer dimension, int[][] startmatrix) {
15
+    public ConwayGameOfLife(Integer dimension, int[][] startMatrix) {
16
+        this.currentGen = startMatrix;
16 17
         this.displayWindow = new SimpleWindow(dimension);
18
+        this.nextGen = new int[dimension][dimension];
17 19
     }
18 20
 
19 21
     public static void main(String[] args) {
@@ -26,22 +28,45 @@ public class ConwayGameOfLife {
26 28
     // allocates and returns the starting matrix of size 'dimension'
27 29
 
28 30
     private int[][] createRandomStart(Integer dimension) {
29
-        return new int[1][1];
31
+        int [][] random = new int[dimension][dimension];
32
+        for(int i = 0; i < random.length; i ++){
33
+            for(int j = 0; j < random.length; j++){
34
+                random[i][j] = (int) Math.round(Math.random());
35
+            }
36
+        }
37
+        return random;
30 38
     }
31 39
 
32 40
     public int[][] simulate(Integer maxGenerations) {
33
-        return new int[1][1];
41
+        for (int i = 0; i <= maxGenerations; i++) {
42
+            this.displayWindow.display(currentGen, maxGenerations);
43
+            for (int j = 0; j < currentGen.length; j++) {
44
+                for (int k = 0; k < currentGen[j].length; k++) {
45
+                    nextGen[j][k] = isAlive(j, k, currentGen);
46
+                }
47
+            }
48
+            copyAndZeroOut(nextGen, currentGen);
49
+            this.displayWindow.sleep(125);
50
+        }
51
+
52
+        return currentGen;
34 53
     }
35 54
 
36 55
     // copy the values of 'next' matrix to 'current' matrix,
37 56
     // and then zero out the contents of 'next' matrix
38
-    public void copyAndZeroOut(int [][] next, int[][] current) {
57
+
58
+    public void copyAndZeroOut(int[][] next, int[][] current) {
59
+        for (int i = 0; i < next.length; i++) {
60
+            for (int j = 0; j < next[i].length; j++) {
61
+                current[i][j] = next[i][j];
62
+                next[i][j] = 0;
63
+            }
64
+        }
39 65
 
40 66
     }
41 67
 
42
-    // Calculate if an individual cell should be alive in the next generation.
43
-    // Based on the game logic:
44
-	/*
68
+    /*  Calculate if an individual cell should be alive in the next generation.
69
+        Based on the game logic:
45 70
 		Any live cell with fewer than two live neighbours dies, as if by needs caused by underpopulation.
46 71
 		Any live cell with more than three live neighbours dies, as if by overcrowding.
47 72
 		Any live cell with two or three live neighbours lives, unchanged, to the next generation.
@@ -50,27 +75,33 @@ public class ConwayGameOfLife {
50 75
     private int isAlive(int row, int col, int[][] world) {
51 76
         int cellValue = world[row][col];
52 77
         int countOfAlive = 0;
53
-        int [] neighborsValues = getNeighborsArray(row, col, world);
54
-            for (int i = 0; i < neighborsValues.length; i++){
55
-            if (neighborsValues[i] == 1){
78
+        int[] neighborsValues = getNeighborsArray(row, col, world);
79
+        for (int i = 0; i < neighborsValues.length; i++) {
80
+            if (neighborsValues[i] == 1) {
56 81
                 countOfAlive++;
57 82
             }
58 83
         }
59 84
         return checkForNextGen(countOfAlive, cellValue);
60 85
     }
61
-    public int checkForNextGen(int countOfLiveNeighbors, int cellValue){
62
-        if(countOfLiveNeighbors < 2 || countOfLiveNeighbors > 3) {
63
-           cellValue = 0;
86
+
87
+    public int checkForNextGen(int countOfLiveNeighbors, int cellValue) {
88
+        if (countOfLiveNeighbors < 2 || countOfLiveNeighbors > 3) {
89
+            cellValue = 0;
90
+        } else if
91
+                (countOfLiveNeighbors == 3) {
92
+            cellValue = 1;
64 93
         }
65
-        else if
66
-            (countOfLiveNeighbors == 3){
67
-                cellValue = 1;
68
-            }
69 94
         return cellValue;
70 95
     }
71
-
72
-    public int[] getNeighborsArray(int row, int col, int [][] world){
73
-        int [] neighborArray = new int[8];
96
+    /*
97
+    in this method we are checking the rules of the game to see:
98
+    1. if the count of our neighbors is less than 2 or greater than 3 --> it will be dead in the next gen
99
+    2. if the count of our neighbors is equal to 2 or 3 then the cell will be alive in the next gen
100
+    3. other
101
+     */
102
+
103
+    public int[] getNeighborsArray(int row, int col, int[][] world) {
104
+        int[] neighborArray = new int[8];
74 105
         neighborArray[0] = getNeighborValue(row, col - 1, world);
75 106
         neighborArray[1] = getNeighborValue(row + 1, col - 1, world);
76 107
         neighborArray[2] = getNeighborValue(row - 1, col, world);
@@ -82,31 +113,44 @@ public class ConwayGameOfLife {
82 113
 
83 114
         return neighborArray;
84 115
     }
116
+    /*
117
+    the above method is creating a new array that is filled with all of the neighbors' values
118
+    we are calling the method below that will give us the values of each neighbor given the row, col, and [][]
119
+     */
85 120
 
86
-    public int getNeighborValue (int row, int col, int[][] world){
121
+    public int getNeighborValue(int row, int col, int[][] world) {
87 122
         row = checkRowBoundary(row, col, world.length - 1);
88 123
         col = checkColBoundary(row, col, world.length - 1);
89
-        return world [row][col];
124
+        return world[row][col];
90 125
     }
126
+    /*
127
+    this method is getting our neighbors value. We are using world.length - 1 bc we are going to the last element.
128
+    when calling [row][col] we are getting a single int value --> either a 0 or 1
129
+     */
91 130
 
92
-    public int checkRowBoundary (int row, int col, int length){
131
+    public int checkRowBoundary(int row, int col, int length) {
93 132
         int rowBounds = 0;
94
-        if (row < 0){
133
+        if (row < 0) {
95 134
             rowBounds = length;
96 135
         }
97
-        if (row > length){
136
+        else if(row > length) {
98 137
             rowBounds = 0;
99 138
         }
100 139
 
101 140
         return rowBounds;
102 141
     }
142
+    /*
143
+    these two methods, they're checking the boundaries for the columns & rows of our value's neighbors
144
+    if our neighbors are out of bounds then we reassign the values to something in bounds
145
+    --> the reflective position in the [][]
146
+     */
103 147
 
104 148
     public int checkColBoundary(int row, int col, int length) {
105 149
         int colBounds = 0;
106 150
         if (col > length) {
107 151
             colBounds = 0;
108 152
         }
109
-        if (col < 0) {
153
+        else if (col < 0) {
110 154
             colBounds = length;
111 155
         }
112 156