Explorar o código

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 hai 1 ano
pai
achega
ed0f059fff
Modificáronse 2 ficheiros con 7 adicións e 5 borrados
  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,
+};