浏览代码

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,
+};