Sorry im little new to java, but on the little piece of code for th game class on page 80, int diff = getIntent ().getIntExtra (KEY_DIFFICULTY, DIFFICULTY_EASY).. shouldn’t it be (KEY_DIFFICULTY, i)?
The simple answer is ‘No the code is correct as is’.
I think I can see why you think it should be (KEY_DIFFICULTY, i), it’s because the call to ‘putExtra(Game.KEY_DIFFICULTY, i)’ a couple of pages before.
What you need to remember is putExtra is storing a name/value pair (KEY_DIFFICULTY is the name, the value is whatever is in variable i) whereas getIntExtra gets a value associated with a name or a default value if the name does not exist. In the case above DIFFICULTY_EASY is the default value to supply if there is no name/value for KEY_DIFFICULTY.
Wasnt aware getIntExtra () could hold a default value parameter, thx. Also, otherwise i was thinking int diff = getIntent ().getIntExtra (KEY_DIFFICULTY, i) if (diff != null) diff = 0;
Being DIFFICULTY_EASY value is 0...sorry trying to be resourceful in learning ;)