vendredi 21 septembre 2018

Random but each can appear only once

i'm new at programming and i'm making an app with android studio.

I wanted to make a "Random" function. This is what how it looks in java:

final String[] lesquestions = {"random1", "random2", "random3"};


    b_question.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {



            int rando_questions = (int) (Math.random() * 3);

            question.setText(lesquestions[rando_questions]);


        }
    });

It works fine, but i want that when a string appears, it is taken out of the list, so it doesn't appear twice.

Thanks by advance for your help.




Aucun commentaire:

Enregistrer un commentaire