Created
September 26, 2020 09:19
-
-
Save remylavergne/27831d2079c5780f2c095bf8635b0fe9 to your computer and use it in GitHub Desktop.
shuffle_dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
// On crée / reçoit la liste des questions | |
List<Question> questions = [ | |
new Question("Quel temps fait-il ?"), | |
new Question("Que manges-tu ?"), | |
new Question("Quelle est cette couleur ?"), | |
new Question("Quel fruit est-ce ?"), | |
new Question("Quelle est ta voiture préférée ?"), | |
new Question("Quel film regardes-tu ?"), | |
new Question("Où habites-tu ?") | |
]; | |
// On affiche la première question de la liste | |
print("Première question avant mélange => ${questions[0].question}"); | |
// On mélange la liste | |
questions.shuffle(); | |
// On affiche la nouvelle première question | |
print("Première question après mélange => ${questions[0].question}"); | |
} | |
class Question { | |
String question; | |
Question(String question) { | |
this.question = question; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lien vers DartPad : https://dartpad.dev/27831d2079c5780f2c095bf8635b0fe9