Beispiel #1
0
        public OverallFeedback Calculate(Guess guess)
        {
            OverallFeedback result = new OverallFeedback();

            if (guess?.Pieces.Count != _puzzle.Pieces.Count)
            {
                throw new System.InvalidOperationException("guess.Pieces length should match the puzzle.Pieces length");
            }

            List <Piece> puzzlePieces = new List <Piece>(_puzzle.Pieces);
            List <Piece> guessPieces  = new List <Piece>(guess.Pieces);

            setCorrectPieces(ref result, puzzlePieces, guessPieces);
            setSimilarPieces(ref result, puzzlePieces, guessPieces);
            setMisplacedPieces(ref result, puzzlePieces, guessPieces);

            return(result);
        }
Beispiel #2
0
        public Feedback Calculate(Guess guess)
        {
            Feedback result = new Feedback();

            if (guess?.Pieces.Count != _puzzle.Pieces.Count)
            {
                throw new System.InvalidOperationException("guess.Pieces length should match the puzzle.Pieces length");
            }

            List <Piece> puzzlePieces = new List <Piece>(_puzzle.Pieces);
            List <Piece> guessPieces  = new List <Piece>(guess.Pieces);

            result.ReferencingPieces = _piecesToCheck;
            setCorrectPieces(ref result, puzzlePieces, guessPieces);
            setSimilarPieces(ref result, puzzlePieces, guessPieces);

            return(result);
        }