Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Document Format ( 2 attachments)

PDF file Icon
663dc39b8ed3a_962355.pdf

180 KBs PDF File

Word file Icon
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

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Operating System questions

Question

Contrast positive motivation with negative motivation.

Answered: 1 week ago