From e458f81ed469f566ae651aa16540c4c6c9984972 Mon Sep 17 00:00:00 2001 From: Ivan Khutorovyi Date: Fri, 4 Aug 2023 13:52:16 +0300 Subject: [PATCH] fix --- src/makeRobot.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/makeRobot.js b/src/makeRobot.js index fc967851..007b371f 100644 --- a/src/makeRobot.js +++ b/src/makeRobot.js @@ -38,6 +38,9 @@ * @return {Robot} */ function makeRobot(name, wheels, version) { + const EVACUATE_COORDINATE_X = 1400; + const EVACUATE_COORDINATE_Y = 500; + const robot = { name, wheels, @@ -56,41 +59,41 @@ function makeRobot(name, wheels, version) { return `${this.name}: x=${this.coords.x}, y=${this.coords.y}`; }, - goForward(value = 1) { - if (value > 0) { - this.coords.y += value; + goForward(step = 1) { + if (step > 0) { + this.coords.y += step; }; return this; }, - goBack(value = 1) { - if (value > 0) { - this.coords.y -= value; + goBack(step = 1) { + if (step > 0) { + this.coords.y -= step; }; return this; }, - goRight(value = 1) { - if (value > 0) { - this.coords.x += value; + goRight(step = 1) { + if (step > 0) { + this.coords.x += step; }; return this; }, - goLeft(value = 1) { - if (value > 0) { - this.coords.x -= value; + goLeft(step = 1) { + if (step > 0) { + this.coords.x -= step; }; return this; }, evacuate() { - this.coords.x = 1400; - this.coords.y = 500; + this.coords.x = EVACUATE_COORDINATE_X; + this.coords.y = EVACUATE_COORDINATE_Y; }, };