diff --git a/src/makeRobot.js b/src/makeRobot.js index 4bcef1e4..1466bc93 100644 --- a/src/makeRobot.js +++ b/src/makeRobot.js @@ -38,7 +38,58 @@ * @return {Robot} */ function makeRobot(name, wheels, version) { - // write code here + const robot = { + name, + version, + wheels, + coords: { + x: 0, + y: 0, + }, + goForward(steps = 1) { + if (steps > 0) { + this.coords.y += steps; + } + + return this; + }, + goBack(steps = 1) { + if (steps > 0) { + this.coords.y -= steps; + } + + return this; + }, + goRight(steps = 1) { + if (steps > 0) { + this.coords.x += steps; + } + + return this; + }, + goLeft(steps = 1) { + if (steps > 0) { + this.coords.x -= steps; + } + + return this; + }, + evacuate() { + this.coords.x = 1400; + this.coords.y = 500; + + return this; + }, + get info() { + return `name: ${name}, chip version: ${version}, wheels: ${wheels}`; + }, + get location() { + return `${this.name}: x=${this.coords.x}, y=${this.coords.y}`; + }, + + }; + + return robot; } module.exports = makeRobot;