Quellcode durchsuchen

cutting some if statements

Trinh Tong vor 6 Jahren
Ursprung
Commit
5972560798
2 geänderte Dateien mit 3 neuen und 6 gelöschten Zeilen
  1. 1
    1
      .idea/workspace.xml
  2. 2
    5
      src/main/java/com/zipcodeconway/ConwayGameOfLife.java

+ 1
- 1
.idea/workspace.xml Datei anzeigen

@@ -236,7 +236,7 @@
236 236
   <component name="PropertiesComponent">
237 237
     <property name="WebServerToolWindowFactoryState" value="false" />
238 238
     <property name="aspect.path.notification.shown" value="true" />
239
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542848238278" />
239
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542954631305" />
240 240
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
241 241
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
242 242
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />

+ 2
- 5
src/main/java/com/zipcodeconway/ConwayGameOfLife.java Datei anzeigen

@@ -81,10 +81,7 @@ public class ConwayGameOfLife {
81 81
         int count = neighbors(row, col, world);
82 82
         int returnValue = 0;
83 83
 
84
-        if (count == 3) {
85
-            returnValue = 1;
86
-        }
87
-        if (world[row][col] == 1 && count == 2){
84
+        if (count == 3 || (world[row][col] == 1 && count == 2)) {
88 85
             returnValue = 1;
89 86
         }
90 87
 
@@ -111,7 +108,7 @@ public class ConwayGameOfLife {
111 108
                     j = 0;
112 109
                 }
113 110
 
114
-                if (world[i][j] == 1 &&(!(i == row && j == col))) {
111
+                if (world[i][j] == 1 && (!(i == row && j == col))) {
115 112
                     count++;
116 113
                 }
117 114