소스 검색

Move Vector3 class to its own file

ApisNecros 4 달 전
부모
커밋
b79a809901
2개의 변경된 파일27개의 추가작업 그리고 27개의 파일을 삭제
  1. 1 27
      12/12_1.js
  2. 26 0
      12/Vector3.js

+ 1 - 27
12/12_1.js

@@ -1,4 +1,5 @@
 const util = require("util");
+const Vector3 = require("./Vector3");
 
 const input = [
     "<x=14, y=15, z=-2>",
@@ -7,33 +8,6 @@ const input = [
     "<x=-2, y=10, z=-8>",
 ];
 
-class Vector3 {
-    /**
-     * A 3D vector
-     *
-     * @param {number} x The X value of this vector
-     * @param {number} y The Y value of this vector
-     * @param {number} z The Z value of this vector
-     */
-    constructor(x, y, z) {
-        this.x = x;
-        this.y = y;
-        this.z = z;
-    }
-
-    /**
-     * Add another vector to this one
-     *
-     * @param {Vector3} operand The vector to add to this one
-     * @returns {void}
-     */
-    add(operand) {
-        this.x += operand.x;
-        this.y += operand.y;
-        this.z += operand.z;
-    }
-}
-
 /**
  * Find the gravitational influence two moons have on each other
  *

+ 26 - 0
12/Vector3.js

@@ -0,0 +1,26 @@
+module.exports = class Vector3 {
+    /**
+     * A 3D vector
+     *
+     * @param {number} x The X value of this vector
+     * @param {number} y The Y value of this vector
+     * @param {number} z The Z value of this vector
+     */
+    constructor(x, y, z) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+    }
+
+    /**
+     * Add another vector to this one
+     *
+     * @param {Vector3} operand The vector to add to this one
+     * @returns {void}
+     */
+    add(operand) {
+        this.x += operand.x;
+        this.y += operand.y;
+        this.z += operand.z;
+    }
+};