/// <summary> /// Generate Subtraction Expression /// </summary> /// <returns></returns> public static ValueInt2 GenerateSubtraction() { var ret = new ValueInt2(); ret.a = UniversalFunctions.Rand(1, 100); ret.b = UniversalFunctions.Rand(1, ret.a); ret.correctanswer = ret.a - ret.b; ret.displayvalue = Convert.ToString(ret.a) + " - " + Convert.ToString(ret.b) + " ="; return(ret); }
/// <summary> /// Verify correctness of Division (only integer value) /// </summary> /// <param name="value">value from user</param> /// <param name="exp">original value</param> /// <returns></returns> public static bool VerifyDivision(string value, ValueInt2 exp) { int tmp; try { tmp = exp.a / exp.b; } catch (Exception e) { return(false); } return(value == Convert.ToString(tmp)); }
/// <summary> /// Verify correctness of Subtraction /// </summary> /// <param name="value">value from user</param> /// <param name="exp">original value</param> /// <returns></returns> public static bool VerifySubtraction(string value, ValueInt2 exp) { return(exp.a - exp.b == Convert.ToInt32(value)); }
/// <summary> /// Verify correctness of Multiplication /// </summary> /// <param name="value">value from user</param> /// <param name="exp">original value</param> /// <returns></returns> public static bool VerifyMultiplication(string value, ValueInt2 exp) { return(exp.a * exp.b == Convert.ToInt32(value)); }
/// <summary> /// Verify correctness of Addition /// </summary> /// <param name="value">value from user</param> /// <param name="exp">original value</param> /// <returns></returns> public static bool VerifyAddition(string value, ValueInt2 exp) { return(exp.a + exp.b == Convert.ToInt32(value)); }