Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have written a public instance method moveBy() whose first argument is an int representing the distance to move and whose second argument is a

I have written a public instance method moveBy() whose first argument is an int representing the distance to move and whose second argument is a char representing the direction in which to move. It should return no value.

Table 1: Directions and corresponding x and y increments

 Direction xInc yInc (this is not a code) Right 'R' 1 0 Left 'L' -1 0 Up 'U' 0 -1 Down 'D' 0 1 

I need to begin by declaring local int variables xInc and yInc and use the table above to set these for the appropriate increments depending on the supplied argument for direction.

This is what I have done so far: please if someone can correct me and help me! many thanks

public void moveBy(int distance, char direction) { int xInc = 0; int yInc = 0; }

or I tried this for the first bit but it says' identifier expected'.

int xInc = 1,-1, 0, 0 int yInc = 0, 0, -1, 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

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

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions

Question

How did SFAS No. 96 differ from APB Opinion No. 11?

Answered: 1 week ago