Add methods to generate the code necessary for sharing a specific sudoku board
This commit is contained in:
parent
4134013fe9
commit
5a098d8ac5
2 changed files with 16 additions and 0 deletions
|
@ -414,6 +414,7 @@ public class GameController implements IModelChangedListener, Parcelable {
|
|||
return gameBoard.toString();
|
||||
}
|
||||
|
||||
public String getCodeOfField() { return gameBoard.transformToCode(); }
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.secuso.privacyfriendlysudoku.game;
|
|||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import org.secuso.privacyfriendlysudoku.controller.Symbol;
|
||||
import org.secuso.privacyfriendlysudoku.game.listener.IModelChangedListener;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
@ -214,6 +215,20 @@ public class GameBoard implements Cloneable, Parcelable {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
public String transformToCode () {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0; i < field.length; i++) {
|
||||
for (int j = 0; j < field[0].length; j++) {
|
||||
if (field[i][j].getValue() == 0) {
|
||||
sb.append(0);
|
||||
} else {
|
||||
sb.append(Symbol.getSymbol(Symbol.SaveFormat, field[i][j].getValue()-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public boolean isFilled() {
|
||||
return actionOnCells(new ICellAction<Boolean>() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue