Question
How to write the class, using else if statement, for the following code that allows me to move 98382 to 7 using the 'MOVE' command?:
How to write the class, using else if statement, for the following code that allows me to move 98382 to 7 using the 'MOVE' command?:
it("responds with position for move command", function() {
let commands = [
new Command('MOVE', 7),
new Command('STATUS_CHECK')
];
let message = new Message('Test message with two commands', commands);
let rover = new Rover(98382);
let response = rover.receiveMessage(message);
// "updates rovers position correctly when receiving a move command"
// console.log(response.results[1].completed)
expect(rover.position).toEqual(7)
// console.log(response.results)
expect(response.results[1].completed).toEqual(true)
Below is my inaccurate attempt at moving the code. I need to enable the 'test' to pass.
else if (command.position === 'MOVE'){
result.completed = true;
// response = rover.receiveMessage(command)
// this.position = response.messsage
this.position = position
result.rover = {mode: this.mode, LOW_POWER: this.LOW_POWER, position: this.position}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
The provided code snippet simulates a rover receiving commands Lets break down the missing part and the corrected code using else if for the MOVE comm...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Document Format ( 2 attachments)
663dc39b8ed3a_962355.pdf
180 KBs PDF File
663dc39b8ed3a_962355.docx
120 KBs Word File
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started