Exemple #1
0
        //public bool getGameIsWon()
        //{
        //    return _gameStatus.GameIsWon;
        //}

        //public int getCorrectNumbers()
        //{
        //    return _gameStatus.CorrectNumbers;
        //}

        //public int getCorrectPositions()
        //{
        //    return _gameStatus.CorrectPositions;
        //}


        public bool CheckScore(int[] attempt)
        {
            //return _validator.IsValid(attempt) && _validator.InputOutofBounds(attempt) && _validator.InputNotUnique(attempt);
            if (!(_validator.IsValid(attempt)))
            {
                return(false);
            }
            if (!(_validator.InputOutofBounds(attempt)))
            {
                return(false);
            }
            if (!(_validator.InputNotUnique(attempt)))
            {
                return(false);
            }
            //return true;
            // loop through test case IfGameIsWon_ReturnGameStatusIsWonTrue()
            for (var i = 0; i < attempt.Length; i++)
            {
                var result = CalculateScore(code, attempt[i]);

                // returns Correct Numbers and correct positions for the attempt array
                _gameStatus.CorrectNumbers   = result[0];
                _gameStatus.CorrectPositions = result[1];
                if ((_gameStatus.CorrectNumbers == 4) && (_gameStatus.CorrectPositions == 4))
                {
                    _gameStatus.GameIsWon = true;
                    break;
                }
                else
                {
                    _gameStatus.GameIsWon = false;
                }
            }
            return(_gameStatus.GameIsWon);
        }
Exemple #2
0
 public bool CheckScore(int[] attempt)
 {
     return(_validator.InputOutofBounds(attempt) && _validator.IsValid(attempt) && _validator.InputNotUnique(attempt));
 }