コード例 #1
0
ファイル: Anagram.cs プロジェクト: DOrtiz1011/AnagramWebSite
        private void GetMinPhraseLengths()
        {
            MinPhraseLengths = new int[NumWords + 1];

            for (var i = NumWords; i > 0; i--)
            {
                var minLength = 0;

                if (i == NumWords)
                {
                    minLength = HintPhrase.Length;
                }
                else if (i == NumWords - 1)
                {
                    minLength = HintPhrase.Length - (DistinctWordList.Any() ? DistinctWordList.Max(x => x.Length) + 1 : 0);
                }

                MinPhraseLengths[i] = minLength;
            }
        }
コード例 #2
0
ファイル: Anagram.cs プロジェクト: DOrtiz1011/AnagramWebSite
        private void ClearCollections()
        {
            if (DistinctWordList != null)
            {
                DistinctWordList.Clear();
                DistinctWordList = null;
            }

            if (CharCountFromHint != null)
            {
                CharCountFromHint.Clear();
                CharCountFromHint = null;
            }

            if (WordHash != null)
            {
                WordHash.Clear();
                WordHash = null;
            }

            MaxPhraseLengths = null;
            MinPhraseLengths = null;
        }
コード例 #3
0
        }//end NoSpaces(String)

        /// <summary>
        /// Displays all distinct word objects
        /// </summary>
        public void Display()
        {
            DistinctWordList.Sort();
            for (int i = 0; i < DistinctWordList.Count; i++)
            {
                if (i == 0)
                {
                    Console.Write("\n\nThe Distinct Words of the File \n\n");

                    Console.Write($"    {"Word".PadRight(50, ' ')}Count");
                    Console.Write($"\n    {"----".PadRight(50, ' ')}-----");
                }

                if (i % 20 == 0 && i != 0)
                {
                    Utility.PressAnyKey();
                    Console.Clear();
                    Console.Write("\n\nThe Distinct Words of the File \n\n");

                    Console.Write($"    {"Word".PadRight(50, ' ')}Count");
                    Console.Write($"\n    {"----".PadRight(50, ' ')}-----");
                }


                if (i == (DistinctWordList.Count - 1))
                {
                    Console.Write($"\n{(i + 1).ToString().PadRight(4, ' ')}{DistinctWordList[i].ToString()}");
                    Utility.PressAnyKey();
                    Console.Clear();
                }



                Console.Write($"\n{(i + 1).ToString().PadRight(4, ' ')}{DistinctWordList[i].ToString()}");
            }
        }//end Display()