0

Hi,

Basically im looking to create a simple application that takes in an instruction from the console. The instruction includes the width and length of a grid (x,y), the starting location of a car (x,y on grid), and the instruction to move about on the grid. Essentially an instruction shall look like this:

5 5 2 2 LRLRMRFL

At the moment my program adds this instruction to a string array, this instruction seperated on spaces. Basically i now want to seperate the grid dimensions into a seperate array, and the car location and movements into another.

Anyone have ideas on the best way to program this? Pretty stumped at this point!

Thanks

Edited by Shakeylfc: www

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by javalover
0

Use the String class methods to get the parts of the input String. Use the Integer class method to convert a String part to an int. When the parts are separated they can be put into the places where you want them to go.

0

Hi friend.. Use the split(reg) method in String class to separate Strings after each space and use parseInt() to access your grid dimensions...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.