最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - How to assure that every question on the quiz has the right question? - Stack Overflow

programmeradmin2浏览0评论

I have this simple app that works like a quiz. The main problem is that sometimes, some questions don't show the right option, as there is only 4 buttons for options and more than 10 items on the list. Here is the code:

    private void createOptions() {
        List<String> options;

        if ("Intervalo Musical".equals(receivedText)) {
            options = new ArrayList<>(Globals.intervalos);
        } else if ("Qualidade do Acorde".equals(receivedText)) {
            options = Arrays.asList("Maior", "Menor", "Diminuto", "Aumentado");
        } else if ("Escala Musical".equals(receivedText)) {
            options = new ArrayList<>(Globals.escalas);
        } 
        /*else {
            options = Arrays.asList("Opção 1", "Opção 2", "Opção 3", "Opção 4");
        }
    */
    if (!options.contains(QUESTION_CORRECT)) {
        options.add(QUESTION_CORRECT);
    }

        Collections.shuffle(options);
        quizOptionA.setText(options.get(0));
        quizOptionB.setText(options.get(1));
        quizOptionC.setText(options.get(2));
        quizOptionD.setText(options.get(3));

    }

and here is where QUESTION_CORRECT is setted:


    private void createSound() {
        String midiFileName = intent.getStringExtra("midiFileName");
        if (midiFileName != null) {
            SOUND_PATH = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC) + "/EAR/" + midiFileName + ".mid";
            File file = new File(SOUND_PATH);

            if (file.exists()) {
                Log.i("SoundCheck", "Arquivo .mid encontrado: " + SOUND_PATH);
                QUESTION_CORRECT = midiFileName;
            } else {
                Log.e("SoundCheck", "Arquivo .mid não encontrado: " + SOUND_PATH);
            }
        } else {
            Log.e("SoundCheck", "midiFileName é nulo");
        }
    }

what am I missing?

trying to put the right answer to be shown on every question of the quiz

发布评论

评论列表(0)

  1. 暂无评论