과제로 문제풀이 앱 만들어서 돌리는 데요 ㅡㅜㅜ
몇 문제 안만드는 터라
1.문제 2.선택지 3.정답 클래스를 만들어서
랜덤으로 돌려서 정답 클래스랑 중복되면 정답처리 되게 끔 만들었어요
그런데 문제가
문제의 중복제거가 적용이 안되서 고통스럽습ㄴㅣ다
앱 제작소에 그 기능만 추가해줄 수 있냐고 하니 삼십만원을 요구하고
ㅜㅜㅠ후긓규ㅜㅜ 밑에 소스인데 도와주시면 정말정말 감사하겠습니다ㅜㅜ
public class activity_c_button_check extends AppCompatActivity {
TextView question;
TextView answer1, answer2, answer3, answer4;
private Questions1 mQuestions = new Questions1();
private String mAnswer;
private int mScore = 0;
private int mQuestionsLength = mQuestions.mQuestions.length;
Random r;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_c_button_check);
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
ActionBar actionBar = getSupportActionBar();
r = new Random();
answer1 = (TextView) findViewById(R.id.answer1);
answer2 = (TextView) findViewById(R.id.answer2);
answer3 = (TextView) findViewById(R.id.answer3);
answer4 = (TextView) findViewById(R.id.answer4);
question = (TextView) findViewById(R.id.question);
updateQuestion(r.nextInt(mQuestionsLength));
answer1.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
if(answer1.getText() == mAnswer){
mScore++;
updateQuestion(r.nextInt(mQuestionsLength));
} else {
gameOver();
}
}
});
answer2.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
if(answer2.getText() == mAnswer) {
mScore++;
updateQuestion(r.nextInt(mQuestionsLength));
} else{
gameOver();
}
}
});
answer3.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
if(answer3.getText() == mAnswer) {
mScore++;
updateQuestion(r.nextInt(mQuestionsLength));
} else{
gameOver();
}
}
});
answer4.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
if(answer4.getText() == mAnswer){
mScore++;
updateQuestion(r.nextInt(mQuestionsLength));
} else{
gameOver();
}
}
});
if(actionBar != null){
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
private void updateQuestion(int num){
question.setText(mQuestions.getQuestion(num));
answer1.setText(mQuestions.getChoice1(num));
answer2.setText(mQuestions.getChoice2(num));
answer3.setText(mQuestions.getChoice3(num));
answer4.setText(mQuestions.getChoice4(num));
mAnswer = mQuestions.getCorrectAnsewer(num);
}
private void gameOver() {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(activity_c_button_check.this);
alertDialogBuilder.setMessage("끝났습니다. 당신의 점수는"+mScore+" 점 입니다")
.setNegativeButton("틀렸습니다",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
updateQuestion(r.nextInt(mQuestionsLength));
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
}