java - Transfering values from an object in a ArrayList to an array sudoku board -


I will explain to you my problem: I will have to fill out this grid:

  Fixed int board [] [] = New int [] [] {{0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0 , 0,0,0,0,0, 0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0 , 0,0}, {0,0,0, 0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, {0,0,0,0,0,0,0,0,0,0,0}, {0 , 0,0,0,0,0,0,0,0,0,0,0}}}};   

But I want to transfer prices within my arraylist objet (ligne, colone, valeur):

  case case1 = new case (ligne, Colon, valor); MonArrayCase.add (case1);   

I have already made a scanner and a print to ensure that my arraylist number has been added and it is working ...

My main problem is that I am printing it:

  System.out.println (Sudoku.board [leagne -1] [colon -1] = valor);   

I can add numbers but I can not delete them ... Maybe I'm doing this in the array ... is there any way to print the value from my arraylist object Thanks in advance.

If I understand you correctly, then you already have the setup:

  • You have some ArrayList & lt; Case & gt;
  • 81 case s, where each case contains a line ( ligne in monArrayCase ), column ( cologne ), and value ( valeur ) each of which is between 1 and 9 (hence the println 0-indexing adjustment in the statement)

    With it, you have your 2D array if I got it backward, go to the end < P> Write some methods to manipulate cells in the board:

      Fixed zero inserted Curse Board (Case Case) {Sudokuboard [case.ligne-1] [case.colone-1] = Case. Vellur; } Static zero extraction caseFromBoard (int ligne, int colon) {sudoku.board [leagne -1] [colon -1] = 0; } For static zero-free bore (for (for int i = 0; i & lt; 9; i ++) {for (int j = 0; j and lt; 9; j ++) {sudoku.board [ I] [J] = 0;}}}   

    and a rerun through the ArrayList & lt; Case & gt; and insert all the values :

      Fixed zero filling (array list and lt; case & in;) {clear bore (for episode ace in these arrays) {insertCaseToBoard (acise)}}}   

    If you already populate the ArrayList & lt; Case & gt; with the board set If you want to do something simple:

      Fixed Arrestist  ListFromBoard () {ArrayList  MyList = New Arrelist & lt; Case & gt; (For int i = 0; i    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -