ソースを参照

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 年間 前
コミット
ed0f059fff
2 ファイル変更7 行追加5 行削除
  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,
+};