void MakeQuiz() { int count = possibleQuestions.Count; int[] order = new int[count]; for (int i = 0; i < count; i++) { order[i] = i; } // shuffle the order order = Shuffle(order); // create quiz quiz = new List <TantanganQuiz>(); for (int i = 0; i < count; i++) { TantanganQuestion q = possibleQuestions[order[i]]; TantanganAnswer answer = q.answer; // this logic is still wronggg int wrongOneId = 0; int wrongTwoId = 0; do { wrongOneId = rand.Next(0, count); } while(answer.id == wrongOneId); do { wrongTwoId = rand.Next(0, count); } while(answer.id == wrongTwoId || wrongOneId == wrongTwoId); TantanganAnswer wrongOne = possibleAnswers.Find(x => x.id == wrongOneId); TantanganAnswer wrongTwo = possibleAnswers.Find(x => x.id == wrongTwoId); TantanganAnswer[] answerArray = Shuffle <TantanganAnswer>( new TantanganAnswer[] { answer, wrongOne, wrongTwo } ); List <TantanganAnswer> answerList = new List <TantanganAnswer>(answerArray); quiz.Add(new TantanganQuiz(q, answerList)); } }
public void Setup() { rand = new System.Random(); possibleQuestions = new List <TantanganQuestion>(); possibleAnswers = new List <TantanganAnswer>(); for (int i = 0; i < clips.Count; i++) { TantanganAnswer answer = new TantanganAnswer(i, answers[i], buttonImages[i]); TantanganQuestion question = new TantanganQuestion(clips[i], answer); possibleQuestions.Add(question); possibleAnswers.Add(answer); } MakeQuiz(); }
public TantanganQuiz(TantanganQuestion q, List <TantanganAnswer> c) { _question = q; _choices = c; }