2 つのクラス間で値を渡したいのですが、次のエラーが発生します。
トークン ";" の構文エラー、別のクラスから呼び出された値を初期化するときに予想される
初期値を持つクラス
public class Game extends Activity implements OnClickListener{
RandomMathQuestionGenerator question = new RandomMathQuestionGenerator();
private static final String TAG= "Sudoku";
public static final String KEY_DIFFICULTY =
"org.example.sudoku.difficulty";
public static final int DIFFICULTY_NOVICE = 1;
public static final int DIFFICULTY_EASY = 2;
public static final int DIFFICULTY_MEDIUM = 3;
public static final int DIFFICULTY_GURU = 4;
public int value = 0;
private GameView gameView;
public Game()
{
if (KEY_DIFFICULTY == String.valueOf(1))
{
value = 2;
}
else if (KEY_DIFFICULTY == String.valueOf(2))
{
value = 3;
}
else if (KEY_DIFFICULTY == String.valueOf(3))
{
value = 4;
}
else if (KEY_DIFFICULTY == String.valueOf(4))
{
value = 6;
}
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate");
}
@Override
public void onClick(View v)
{
//code here
}
}
値を呼び出すクラス
public class RandomMathQuestionGenerator {
Game num = new Game();
int number = 0;
number = num.Game(value);
//public int number = 0;
//number = num.Game(number);
private static final int NUMBER_OF_QUESTIONS = 1;
private static final int MIN_QUESTION_ELEMENTS = 2;
private final int MAX_QUESTION_ELEMENTS = number;
private static final int MIN_QUESTION_ELEMENT_VALUE = 1;
private static final int MAX_QUESTION_ELEMENT_VALUE = 100;
private final Random randomGenerator = new Random();
//rest of irrelevant code below
}