![]() | Continue |
|
28 Aug 2012, 12:30
Sheetal Agarwal (4 posts) |
My program is giving no errors but it is not able to implement the continue operation instead it always shows the new game of difficulty easy.My code is as follows: Game.java public class Game extends Activity { private static final String TAG=”Sudoku”; public static final String KEY_DIFFICULTY=”sudoku.game.difficulty”; public static final int DIFFICULTY_EASY=0; public static final int DIFFICULTY_MEDIUM=1; public static final int DIFFICULTY_HARD=2; private int puzzle[]=new int[9*9]; private PuzzleView puzzleView; private static final String PREF_PUZZLE=”puzzle”; protected static final int DIFFICULTY_CONTINUE=-1; @Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
Log.d(TAG,”onCreate”);
int diff=getIntent().getIntExtra(KEY_DIFFICULTY, DIFFICULTY_EASY);
puzzle=getPuzzle(diff);
calculateUsedTiles();
puzzleView=new PuzzleView(this);
setContentView(puzzleView);
puzzleView.requestFocus();
getIntent().putExtra(KEY_DIFFICULTY, DIFFICULTY_CONTINUE);
} @Override
//... private int[]getPuzzle(int diff){ String puz; switch(diff){ case DIFFICULTY_CONTINUE: puz=getPreferences(MODE_PRIVATE).getString(PREF_PUZZLE, easyPuzzle); case DIFFICULTY_HARD: puz=hardPuzzle; break; case DIFFICULTY_MEDIUM: puz=mediumPuzzle; break; case DIFFICULTY_EASY: default: puz=easyPuzzle; break; } return fromPuzzleString(puz); } Sudoku.java public void onClick(View v) { // TODO Auto-generated method stub switch(v.getId()){ case R.id.button3: Intent i=new Intent(this, About.class); startActivity(i); break; case R.id.button2: openNewGameDialog(); break; case R.id.button4: finish(); break; case R.id.button1: startGame(Game.DIFFICULTY_CONTINUE); break; } Please help me to resolve my problem. |
| You must be logged in to comment |

