public void CreateProblem(MathFamily family, int highestValue) { int firstValue = RandomNumber(highestValue); int secondValue = RandomNumber(highestValue); switch (family) { case MathFamily.Addition: operatorLbl.Text = "+"; correctAnswer = firstValue + secondValue; break; case MathFamily.Subtraction: operatorLbl.Text = "-"; secondValue = RandomNumber(firstValue); correctAnswer = firstValue - secondValue; break; case MathFamily.Multiplication: operatorLbl.Text = "X"; correctAnswer = firstValue * secondValue; break; case MathFamily.Division: operatorLbl.Text = "%"; secondValue = RandomNumber(highestValue - 1) + 1; firstValue = firstValue * secondValue; correctAnswer = firstValue / secondValue; break; default: break; } topNumberLbl.Text = firstValue.ToString(); lowerNumberLbl.Text = secondValue.ToString(); }
private void ChooseMathType() { Random random = new Random((int)DateTime.Now.Ticks); TypeOfMath = (MathFamily)random.Next(2); }