Skip to content

Commit

Permalink
Complete Task
Browse files Browse the repository at this point in the history
  • Loading branch information
Annbpiu committed Aug 15, 2023
1 parent 9dd4651 commit 2f37448
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion src/makeRobot.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,62 @@
* @return {Robot}
*/
function makeRobot(name, wheels, version) {
// write code here
const robot = {
name,
wheels,
version,
coords: {
x: 0,
y: 0,
},

get info() {
return `name: ${this.name}, chip version: ${this.version}, wheels: ${this.wheels}`;

Check failure on line 51 in src/makeRobot.js

View workflow job for this annotation

GitHub Actions / build (12.x)

Line 51 exceeds the maximum line length of 80
},

get location() {
return `${this.name}: x=${this.coords.x}, y=${this.coords.y}`;
},

evacuate(value) {
this.coords.x = 1400;
this.coords.y = 500;
},

goForward(value = 1) {
if (value > 0) {
this.coords.y += value;
}

return this;
},

goBack(value = 1) {
if (value > 0) {
this.coords.y -= value;
}

return this;
},

goRight(value = 1) {
if (value > 0) {
this.coords.x += value;
}

return this;
},

goLeft(value = 1) {
if (value > 0) {
this.coords.x -= value;
}

return this;
},
};

return robot;
}

module.exports = makeRobot;

0 comments on commit 2f37448

Please sign in to comment.