java - Stuck on this bit of code -


What I'm doing is creating a command line "Game" where there is a 3x3 grid where you have "1" By typing direction (top, bottom, left, right)

For example:

0 0 0

0 0 0

0 0 0

I have made it, if 1 is on the edge of the array then it is not allowed to go beyond the boundaries (read: resulting in an index error).

I am completely lost whenever I try to move right, I receive the following:

  Exception in thread "main" java.lang. ArrayIndexOutOfBoundsException: Logic.setMove at 3 (Logic.java:87) on Logic.getMove (Logic .java: 10) at GridGameMain.main (GridGameMain.java13)   

This is my code:

  public class GridGameMain {static int [] [] board = new int [3] [3]; Public Static Zero Main (String [] Args) {Board [(Int.) (Math.Rendam) * 2.5)] [(Int. (Math.Rendem) * 2.5)] = 1; For (int i = 0; i   

I'm not sure that I can not move right when I can move up, down, and just fine. Please tell me that I am not mad!

I think there is a problem, to make sure you check that 1 is not correct yet, and then you start moving things right. It is a lobby that, if your 1 column was on 0, it has been moved to 2 column, then on the next and last trip, it has been moved to 3 column.

Apart from this Are you making sure that it does not happen when you go down? It's not happening because the kapil says that you get out of the "rows" (relevant) loop, while moving right You are one of the pillars, which is not what you wanted.

Its al Or, you can use the tag to break out of it, whatever you want to loop. .

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -