-2

I have class called QuestionsAll with constructor:

QuestionsAll(label question, Button b1, Button b2, Button b3, Button b4)

and method called:

questions(string question, string answer1, string answer2, string answer3, string answer4, Button correctanswer)   

How I use it in my form:

void NewQuestion()    
{
    Random rd = new Random();
    int qu = rd.Next(0,4)
    QuestionsAll q = new QuestionsAll(label1,Button1,Button2,Button3,Button4) //my question will be in label1, answer1 in Button1......)

    if(qu == 1) q.questions("1+1 =", "1", "2", "3", "4", Button2);
    if(qu == 2) q.questions("1+2 =", "1", "2", "3", "4", Button3);
}

And when you click in right question, question changes, but questions and answers repeat. How can I do it without repeat?

AGB
  • 2,230
  • 1
  • 14
  • 21
  • You need to include more information on the current behavior and the behavior you expect. – MikeC Apr 10 '16 at 03:18

1 Answers1

2

If I get it right, you want to go through all the question just once? If so, make list of integers which symbolizes the questions. Once the question passes, delete it from list. Like this:

List<int> questions = new List<int>();
for (int i = 0; i < 5; i++){
    list.add(i);
}
//...
int qu = rd.Next(0, questions.Count);
//... Question is answered
questions.Remove(qu);
Korhak
  • 82
  • 9
  • Korhak : And where should i add that method q.questions("1+1 =", "1", "2", "3", "4", Button2) ?? – Petr Konecny Apr 10 '16 at 11:17
  • I don't know whole structure of your program, so you have to think for yourself a bit. You keep the structure as you have, just replace the line with int qu = ... And at the end you call questions.Remove(qu) and then the method can be called again. – Korhak Apr 10 '16 at 12:52