Exemplo n.º 1
0
        public static AnswerDigit GenerateRamdomAnswerDigit()
        {
            var digit = new AnswerDigit();

            digit.GenerateRamdomNumber();
            return(digit);
        }
Exemplo n.º 2
0
        public void AnswerDigitRandomlyGenerated()
        {
            AnswerDigit answerDigit = new AnswerDigit();
            answerDigit.GenerateRamdomNumber();

            Assert.That(answerDigit.Number > 0 && answerDigit.Number < 10, "Random answer number not between acceptable ranges.");
        }
Exemplo n.º 3
0
 /// <summary>
 /// Process all the user's inputs
 /// </summary>
 /// <param name="userInput"></param>
 public void ProcessAnswer(int[] userInput)
 {
     for (int currentAnswerDigits = 0; currentAnswerDigits < AnswerDigits.Count; currentAnswerDigits++)
     {
         AnswerDigit answerDigit = AnswerDigits[currentAnswerDigits];
         answerDigit.MatchStatus = MatchInputAtCurrentPosition(answerDigit, userInput[currentAnswerDigits]);
     }
 }
Exemplo n.º 4
0
        private AnswerDigit.Status MatchInputAtCurrentPosition(AnswerDigit answerDigit, int currentInput)
        {
            if (answerDigit.Matches(currentInput))
            {
                return(AnswerDigit.Status.Match);
            }

            if (IsInAnswer(currentInput))
            {
                return(AnswerDigit.Status.WrongPosition);
            }

            return(AnswerDigit.Status.Nonmatch);
        }
Exemplo n.º 5
0
        public IList <AnswerDigit> GenerateRandomAnswers(int count)
        {
            var digits = new Dictionary <int, AnswerDigit>();

            while (digits.Count < count)
            {
                AnswerDigit digit = AnswerDigit.GenerateRamdomAnswerDigit();

                if (!digits.ContainsKey(digit.Number))
                {
                    digits.Add(digit.Number, digit);
                }
            }

            return(digits.Values.ToList());
        }
Exemplo n.º 6
0
        private AnswerDigit.Status MatchInputAtCurrentPosition(AnswerDigit answerDigit, int currentInput)
        {
            if (answerDigit.Matches(currentInput))
            {
                return AnswerDigit.Status.Match;
            }

            if (IsInAnswer(currentInput))
            {
                return AnswerDigit.Status.WrongPosition;
            }

            return AnswerDigit.Status.Nonmatch;
        }
Exemplo n.º 7
0
 public Answer(int numberOfAnswerDigits)
 {
     this.numberOfAnswerDigits = numberOfAnswerDigits;
     AnswerDigits = new AnswerDigit[numberOfAnswerDigits];
 }
Exemplo n.º 8
0
 public static AnswerDigit GenerateRamdomAnswerDigit()
 {
     var digit = new AnswerDigit();
     digit.GenerateRamdomNumber();
     return digit;
 }
Exemplo n.º 9
0
 public void AnswerDigitMatches()
 {
     AnswerDigit answerDigit = new AnswerDigit(5);
     Assert.That(answerDigit.Matches(5), "Equality check does not identify matches.");
 }
Exemplo n.º 10
0
 public void AnswerDigitDoesNotMatch()
 {
     AnswerDigit answerDigit = new AnswerDigit(5);
     Assert.IsFalse(answerDigit.Matches(1), "Equality check does not indentify non-matches.");
 }
Exemplo n.º 11
0
 private string GetStatusSymbol(AnswerDigit.Status status)
 {
     switch (status)
     {
         case (AnswerDigit.Status.Match):
             { return "✔"; }
         case (AnswerDigit.Status.Nonmatch):
             { return "✗"; }
         default:
             { return "O"; }
     }
 }