Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vannnkof committed Aug 4, 2023
1 parent acf608b commit e458f81
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/makeRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
},
};

Expand Down

0 comments on commit e458f81

Please sign in to comment.