bool CalculateAnswer() { // Randomly choose what score we're entering for. entryNum = RNG.Range(0, 5); // Random score generation. highScores[0].score = RNG.Range(500, 100500) * 10; if (highScores[0].score > 999990) { highScores[0].score = 999990; } for (int i = 1; i < 5; ++i) { highScores[i].score = RNG.Range(highScores[i - 1].score / 13, highScores[i - 1].score / 10) * 10; } // Random name generation. for (int i = 0; i < 5; ++i) { highScores[i].name = ((i == entryNum) ? "___" : RandomName()).ToCharArray(); } // Calculation start AnswerCalculator ac = new AnswerCalculator(bombInfo.GetSerialNumber(), highScores, entryNum); try { correctName = ac.DoCalculation(); } catch (Exception) { //Debug.LogFormat("[The High Score #{0}] Exception during processing: {1}", thisLogID, e.ToString()); //Debug.LogFormat("[The High Score #{0}] Log at that point:", thisLogID); //foreach (string s in ac.log) // Debug.LogFormat("[The High Score #{0}] {1}", thisLogID, s); return(false); } // Calculation end if (BadWordPresent(correctName)) { return(false); } foreach (string s in ac.log) { Debug.LogFormat("[The High Score #{0}] {1}", thisLogID, s); } highScores[entryNum].name = "A__".ToCharArray(); return(true); }
public void ShouldFindCorrectAnswerForExample2() { var result = new AnswerCalculator().Calculate2(ExampleData); result.ShouldBe(241861950); }
public void ShouldFindCorrectAnswerForExample1() { var result = new AnswerCalculator().Calculate1(ExampleData); result.ShouldBe(514579); }