Beispiel #1
0
        public static bool CorrectLetter(char letter)
        {
            string secretWordTrimmed = SecretWord.Trim();

            string[] splitWord = secretWordTrimmed.Split();

            if (FullWord.Contains(letter))
            {
                for (int i = 0; i <= FullWord.Length - 1; i++)
                {
                    if (FullWord[i] == letter)
                    {
                        splitWord[i] = letter.ToString();
                    }
                }
                SecretWord      = string.Join(" ", splitWord);
                IsCorrectLetter = true;
                if (!SecretWord.Contains('_'))
                {
                    GameWon = true;
                    return(GameWon);
                }
                return(IsCorrectLetter);
            }
            else
            {
                IsCorrectLetter = false;
                CountGuesses++;
                return(IsCorrectLetter);
            }
        }
Beispiel #2
0
 public void CorrectGuess()
 {
     if (!SecretWord.Contains(GuessLetters.LastOrDefault()))
     {
         Guesses--;
     }
 }
        private void CheckLetter(string letter)
        {
            var found = false;

            for (int i = 0; i < word.Length; i++)
            {
                if (word[i].ToString() == letter)
                {
                    found         = true;
                    SecretWord[i] = letter;
                }
            }

            if (!found)
            {
                errors      += 1;
                HangmanImage = $".\\images\\{errors}.png";
                if (errors == 6)
                {
                    MessageBox.Show("You Lose!!!", "Nooo!!!");
                    ResetGame();
                }
            }
            else
            {
                if (SecretWord.All(x => x != "?"))
                {
                    MessageBox.Show("You Win!!!", "Yes!!!");
                    ResetGame();
                }
            }
        }
Beispiel #4
0
        public void PickLetter(char c)
        {
            if (RemainingAttempts < 1)
            {
                throw new InvalidOperationException($"You cannot pick any more letter as you have no more remaining attempts");
            }

            if (RemainingSecretLetters.Count < 1)
            {
                throw new InvalidOperationException($"You cannot pick any more letter as there are no remaining letters");
            }

            UsedLetters.Add(c);

            var upperChar = char.ToUpper(c);

            if (SecretWord.Contains(upperChar))
            {
                RemainingSecretLetters.Remove(upperChar);
            }
            else
            {
                RemainingAttempts--;
            }
        }
        public Result <string> Guess(char g)
        {
            if (!validCharacters.Contains(g))
            {
                return(Result.Failure <string>("Invalid Guess"));
            }

            if (IncorrectGuesses.Contains(g) || CorrectGuesses.Contains(g))
            {
                return(Result.Failure <string>("Duplicate Guess"));
            }

            if (!SecretWord.Contains(g))
            {
                IncorrectGuesses.Add(g);
                return(Result.Failure <string>("Incorrect Guess"));
            }

            CorrectGuesses.Add(g);

            GameStateSecretWord = GameStateSecretWord.Replace(g.ToString(), "");

            if (string.IsNullOrWhiteSpace(GameStateSecretWord))
            {
                return(Result.Success("Game won!!!"));
            }

            return(Result.Success("Correct Guess"));
        }
Beispiel #6
0
 private bool IsCorrectGuess(string guess)
 {
     if (SecretWord.Contains(guess))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #7
0
        public void DisplayStatus()
        {
            Console.WriteLine("Won: {0}", Won());
            Console.WriteLine("you have {0} guesses left", Guesses);

            writeList("Available letters to guess: ", AvailableLetters);
            writeList("Guess letters: ", GuessLetters);

            var i = SecretWord.Select(letter => GuessLetters.Contains(letter) ? letter : '_');

            Console.Write(string.Join(' ', i));

            Console.WriteLine();
        }
Beispiel #8
0
        public bool IsCorrectCompleteWord()
        {
            bool test = true;

            foreach (var character in SecretWord.ToCharArray())
            {
                if (!guesses.Contains(character) && character != ' ')
                {
                    test = false;
                }
                ;
            }
            return(test);
        }
Beispiel #9
0
 private bool CheckData(HttpRequest req)
 {
     return(!new[]
     {
         "pay_to_email",
         "pay_from_email",
         "merchant_id",
         "transaction_id",
         "mb_transaction_id",
         "mb_amount",
         "mb_currency",
         "status",
         "md5sig",
         "amount",
         "currency"
     }.Any(field => string.IsNullOrEmpty(req[field]))
            &&
            (req["merchant_id"] +
             req["transaction_id"] +
             SecretWord.Md5(true, Encoding.ASCII) +
             req["mb_amount"] +
             req["mb_currency"] +
             req["status"]).Md5() == req["md5sig"]);
 }
Beispiel #10
0
        private UploadAppSampleDataDictionary GetSampleData()
        {
            var r = new UploadAppSampleDataDictionary
            {
                ApplicationType            = ApplicationType.XKeys(),
                CreditTermAsked            = new[] { CreditTermAskedFrom.Text.Toi(), CreditTermAskedTo.Text.Toi() },
                DepositTermAsked           = new[] { DepositTermAskedFrom.Text.Toi(), DepositTermAskedTo.Text.Toi() },
                CreditLimitAsked           = new[] { CreditLimitAskedFrom.Text.Toi(), CreditLimitAskedTo.Text.Toi() },
                DepositLimitAsked          = new[] { DepositLimitAskedFrom.Text.Toi(), DepositLimitAskedTo.Text.Toi() },
                CardCategory               = CardCategory.XKeys(),
                PaternalNameM              = PaternalNameM.XVals(),
                NameM                      = NameM.XVals(),
                LastNameM                  = LastNameM.XVals(),
                PaternalNameG              = PaternalNameG.XVals(),
                NameG                      = NameG.XVals(),
                LastNameG                  = LastNameG.XVals(),
                IsSecondNameNOTChanged     = IsSecondNameNOTChanged.XKeys(),
                PreviousSecondName         = PreviousSecondName.XVals(),
                PlaceOfBirth               = PlaceOfBirth.XVals(),
                BirthDate                  = new[] { BirthDateFrom.Value, BirthDateTo.Value },
                Gender                     = Gender.XKeys(),
                IssuedOn                   = new[] { IssuedOnFrom.Value, IssuedOnTo.Value },
                IssuePlace                 = IssuePlace.XVals(),
                IssuedBy                   = IssuedBy.XVals(),
                LineCodeKLADR              = LineCodeKLADR.XKeys(),
                Building                   = new[] { BuildingFrom.Text.Toi(), BuildingTo.Text.Toi() },
                DeliveryAddress            = DeliveryAddress.XKeys(),
                AccountName                = AccountName.XVals(),
                AccountType                = AccountType.XKeys(),
                LaborContractType          = LaborContractType.XKeys(),
                TotalWorkExperience        = TotalWorkExperience.XKeys(),
                LastSeniority              = LastSeniority.XKeys(),
                JobTitle                   = JobTitle.XKeys(),
                AverageMonthlyIncome       = new[] { AverageMonthlyIncomeFrom.Text.Toi(), AverageMonthlyIncomeTo.Text.Toi() },
                IncomeCheckStatus          = IncomeCheckStatus.XKeys(),
                DeliveryAddressV           = DeliveryAddressV.XKeys(),
                Education                  = Education.XKeys(),
                MaritalStatus              = MaritalStatus.XKeys(),
                MinorChildrenNummber       = MinorChildrenNummber.XKeys(),
                ContactName                = ContactName.XVals(),
                RelationDegree             = RelationDegree.XKeys(),
                IsNotPublicPerson          = IsNotPublicPerson.XKeys(),
                MaidenName                 = MaidenName.XVals(),
                SecretQuestion             = SecretQuestion.XKeys(),
                PreviousCreditsQuantity    = PreviousCreditsQuantity.XKeys(),
                AccountSphere              = AccountSphere.XKeys(),
                AccountCompanyEmployeesQty = AccountCompanyEmployeesQty.XVals(),
                SecretWord                 = SecretWord.XVals(),
                BankingServiceCredit       = BankingServiceCredit.XKeys(),
                BankingServiceDebit        = BankingServiceDebit.XKeys(),
                CurrencyAsked              = CurrencyAsked.XKeys(),
                IsAgreeAuthorityTransfer   = IsAgreeAuthorityTransfer.XKeys(),
                IsDataAuthentic            = IsDataAuthentic.XKeys(),
                Street                     = Street.XVals(),
                PercentPayment             = PercentPayment.XVals(),
                PercentPaymentMethod       = PercentPaymentMethod.XVals(),
                DependentsNumber           = DependantsNumber.XKeys(),
                EarlierCreditStatuse       = EarlierCreditStatuse.XKeys(),
                EarlierCreditType          = EarlierCreditType.XKeys(),
                EarlierBank                = EarlierBank.XKeys(),
                EarlierMaxLoanTerm         = EarlierMaxLoanTerm.XKeys(),
                ClientType                 = ClientType.XKeys(),
            };

            return(r);
        }
Beispiel #11
0
        public void IWantThisToRund(string hiddenWord, string starString_expected)
        {
            SecretWord s = new SecretWord(hiddenWord);

            Assert.AreEqual(starString_expected, s.Hidden);
        }
Beispiel #12
0
 public bool Won()
 {
     return(SecretWord.All(letter => GuessLetters.Contains(letter)));
 }