Witajcie,
zastanawiam się jak w tym kodzie getter isAnswerTrue
' wie ', który argument z obiektu Question
jest true
?
private Question[] mQuestionBank = new Question[] {
new Question(R.string.question_australia, true),
new Question(R.string.question_oceans, true),
new Question(R.string.question_mideast, false),
new Question(R.string.question_africa, false),
new Question(R.string.question_americas,true),
new Question(R.string.question_asia, true),
};
public class Question {
private int mTextResId;
private boolean mAnswerTrue;
public int getTextResId() {
return mTextResId;
}
public void setTextResId(int textResId) {
mTextResId = textResId;
}
public boolean isAnswerTrue() {
return mAnswerTrue;
}
public void setAnswerTrue(boolean answerTrue) {
mAnswerTrue = answerTrue;
}
public Question (int textResId, boolean answerTrue){
mTextResId = textResId;
mAnswerTrue = answerTrue;
}
}
.......
// dalej w kodzie jest
boolean answerIsTrue = mQuestionBank[mCurrentIndex].isAnswerTrue();