/// <summary>
    ///  creates 1 correct answer and several incorrect answers for the task
    /// </summary>
    //TODO: improve random incorrect solutions + avoid doubled answers
    private ArrayList createOptions()
    {
        float solution = problem.getSolution();
        ArrayList newOptions = new ArrayList();

        MathOption correctOption = new MathOption(solution, true);
        newOptions.Add(correctOption);

        for (int i = 0; i < amountOfOptions; i++)
        {
            int incorrectSolution = rnd.Next(1, 400);

            while (incorrectSolution == solution)                   //avoids the correct solution occuring additionally as incorrect solution
            {
                incorrectSolution = rnd.Next(1, 400);
            }
            newOptions.Add(new MathOption(incorrectSolution));
        }

        //giving the correct answer a random index
        int index = rnd.Next(0, 11);
        MathOption transAnswer = (MathOption)newOptions[index];
        newOptions[0] = transAnswer;
        newOptions[index] = correctOption;

        return newOptions;
    }
Esempio n. 2
0
 public argClass(MathOption op)
 {
     MathOption = op;
 }