public TestPaper(int n, int range, int length, bool random) { numberOfQuestions = n; papers = new Arithmetic[numberOfQuestions]; for (int i = 0; i < numberOfQuestions; i++) { Arithmetic arith = new Arithmetic(range, length, !random); papers[i] = arith; } }
void InitializeTestPaper() { totalNum = GetTotalNum(); currentNum = 0; leftNum = totalNum - currentNum; wrongNum = 0; testPaper = new TestPaper(totalNum, GetRange(), GetLength(), GetIsRandom()); //初始化从entry里取值string to int怎么搞。 currentArithmetic = testPaper.papers[currentNum]; BindingContext = testPaper; //实际没用上,还不会用binding labelTotalNum.Text = "Total Number: " + totalNum.ToString(); RefleshStatus(); }
//得重写,乱七八糟 void buttomConfirmInput_Clicked(System.Object sender, System.EventArgs e) { //testLabel.Text = entryInputAnswer.Text; if (currentArithmetic.Answer() == entryInputAnswer.Text) //回答正确 { if (currentNum < totalNum - 1) //不是最后一题 { currentNum++; leftNum = totalNum - currentNum; currentArithmetic = testPaper.papers[currentNum]; RefleshStatus(); } else //最后一题 { DisplayAlert("DONE", $"Total:{totalNum},Wrong:{wrongNum},Score:{(int)(100 * (totalNum - wrongNum) / totalNum)}", "YES"); InitializeTestPaper(); RefleshStatus(); } } else { if ((currentArithmetic.Answer() == "+" || currentArithmetic.Answer() == "-") && (currentArithmetic.ArithmeticString()[currentArithmetic.EmptySite() + 1] == "0") && (entryInputAnswer.Text == "+" || entryInputAnswer.Text == "-")) { //照抄正确的那步,应该重写。 if (currentNum < totalNum - 1) //不是最后一题 { currentNum++; leftNum = totalNum - currentNum; currentArithmetic = testPaper.papers[currentNum]; RefleshStatus(); } else //最后一题 { DisplayAlert("DONE", $"Total:{totalNum},Wrong:{wrongNum},Score:{(int)(100 * (totalNum - wrongNum) / totalNum)}", "YES"); InitializeTestPaper(); RefleshStatus(); } } else { wrongNum++; RefleshStatus(); } } }