Prechádzať zdrojové kódy

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 rok pred
rodič
commit
ed0f059fff
2 zmenil súbory, kde vykonal 7 pridanie a 5 odobranie
  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,
+};