Esempio n. 1
0
        public List <int> CheckLetter(Char letter, out string message)
        {
            List <int> matchedIndexs = new List <int>();


            foreach (var c in GuessedCharacters)
            {
                if (letter == c)
                {
                    message = "You have already guessed that letter";
                    return(matchedIndexs);
                }
            }


            for (int i = 0; i < CurrentWord.Length; i++)
            {
                if (Char.ToUpper(letter) == CurrentWord.ToUpper()[i])
                {
                    guessed [i] = Char.ToUpper(letter);
                    matchedIndexs.Add(i);
                }
            }

            if (matchedIndexs.Count == 0)
            {
                message = "That letter wasnt in the word";
                Lives--;
            }
            else
            {
                message = "You guessed correctly";
            }


            GuessedCharacters.Add(letter);
            return(matchedIndexs);
        }
Esempio n. 2
0
        public int[] TakeCharacter(char ch)
        {
            int[] temp = new int[CurrentWord.Length];

            for (int i = 0; i < CurrentWord.Length; i++)
            {
                if (CurrentWord.ToUpper()[i] == ch)
                {
                    temp[i] = 1;
                }
                else
                {
                    temp[i] = 0;
                }
            }

            if (temp.Count(i => i == 1) == 0)
            {
                Stage++;
            }

            return(temp);
        }
Esempio n. 3
0
        public void PreenchendoListaArtigos()
        {
            bool          SaoArtigos   = false;
            int           CountArtigos = 0;
            StringBuilder sb           = new StringBuilder();

            var PalavrasDaJuris = InteiroTeor.Split(' ');
            var PreviousWord    = PalavrasDaJuris.ElementAt(0);

            foreach (var CurrentWord in PalavrasDaJuris)
            {
                if (SaoArtigos)
                {
                    if (CurrentWord.EndsWith(".") || CurrentWord.Equals(".") ||
                        CurrentWord.EndsWith(")") || CurrentWord.Equals(")") ||
                        CurrentWord.EndsWith(":") || CurrentWord.Equals(":") ||
                        CurrentWord.EndsWith(@"\") || CurrentWord.Equals(@"\") ||
                        CurrentWord.EndsWith("\"") || CurrentWord.Equals("\"") ||
                        CurrentWord.EndsWith("\n") || CurrentWord.EndsWith("\r") ||
                        CountArtigos > 8)                                                       //Precisa de um maximo, de ler 8 palavras após achar um "ARTIGOS"
                    {
                        sb.Append(CurrentWord);
                        SaoArtigos   = false;
                        CountArtigos = 0;
                        sb.Clear();
                    }
                    else
                    {
                        sb.Append(CurrentWord);
                        CountArtigos++;
                    }
                }

                else
                {
                    if (PreviousWord.Contains("ARTIGOS") && Util.PalavraContemDigito(CurrentWord))  //Se a palavra anterior é "ARTIGOS" e a atual contem numeros
                    {
                        SaoArtigos = true;

                        sb.Append(CurrentWord);
                    }

                    else if (PreviousWord.Contains("ART.") || PreviousWord.Equals("ARTIGO") || (PreviousWord.Equals("ART")))
                    {
                        if (Util.PalavraContemDigito(CurrentWord))             //Só adicionará a lista de artigos caso a palavra posterior contenha um numero (Ex: Art. 23)
                        {
                            ListaArtigos.Add(CurrentWord);
                        }
                    }
                    else if (CurrentWord.StartsWith("ARTS.") || CurrentWord.StartsWith("ART.") || CurrentWord.StartsWith("art.") || CurrentWord.StartsWith("arts."))
                    {
                        if (Util.PalavraContemDigito(CurrentWord))             //Só adicionará a lista de artigos caso a palavra posterior contenha um numero (Ex: Art. 23)
                        {
                            ListaArtigos.Add(CurrentWord);
                        }
                    }
                }

                PreviousWord = CurrentWord.ToUpper();
            }

            NormalizaArtigos();
        }