Forráskód Böngészése

Move parameter modes to their own file

Both the Computer and the Stack classes need to know the values of the
parameter modes, so these needed to be moved out.
ApisNecros 1 éve
szülő
commit
ed0f059fff
2 módosított fájl, 7 hozzáadás és 5 törlés
  1. 3 5
      IntComp/Computer.js
  2. 4 0
      IntComp/ComputerParameterMode.js

+ 3 - 5
IntComp/Computer.js

@@ -1,4 +1,5 @@
 const Stack = require("./Stack");
+const ComputerParameterMode = require('./ComputerParameterMode');
 
 /**
  * An Intcode Computer for the Advent of Code 2019 challenge
@@ -14,11 +15,8 @@ module.exports = class Computer {
             OUTPUT: 4,
             HALT: 99,
         };
-        this.PARAMETER_MODES = {
-            POSITION_MODE: 0,
-            IMMEDIATE_MODE: 1,
-        }
-        this.paramMode = this.PARAMETER_MODES.POSITION_MODE;
+
+        this.paramMode = ComputerParameterMode.POSITION_MODE;
     }
 
     /**

+ 4 - 0
IntComp/ComputerParameterMode.js

@@ -0,0 +1,4 @@
+module.exports = {
+	POSITION_MODE: 0,
+	IMMEDIATE_MODE: 1,
+};