Exemplo n.º 1
0
        static void Main(string[] args)
        {
            MyText text = new MyText();

            text.AddText("123456789");
            //text.Text = null;
            text.AddText("123dfghedjh456789");
            text.Clear();

            text.AddText("dsaad gedgher asd");
            text.AddText("12345");
            text.AddText("dsaad gedgher asdq  w qeqweq");
            text.AddText("ds324d  asd");
            text.AddText("sfeuwy weqpd fqqpew");
            Console.WriteLine("Max={0}", text.GetMaxLenght());
            text.Remove(1);
            text.RemoveAll("dsa");
            text.ToUpperText();
            for (int i = 0; i < text.Count(); i++)
            {
                Console.WriteLine(text.Text[i].GetString());
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            MyText curText = new MyText(),
                   menu    = new MyText();
            int choise     = -1;

            menuInit(menu);

            while (true)
            {
                Console.WriteLine("Current text:");
                curText.WriteLine();
                Console.WriteLine();
                Console.WriteLine();

                switch (choise)
                {
                case (1):
                    Console.Write("\nType a position of new string (0 to go to main menu): ");
                    int      strNum    = GetInt();
                    MyString curString = new MyString();
                    if (Convert.ToBoolean(strNum))
                    {
                        Console.Write("\nType a string: ");
                        curString.getline();
                        curText.AddString(curString, strNum);
                    }
                    else
                    {
                        choise = -1;
                    }
                    break;

                case (2):
                    Console.Write("\nType a position to delete a string (0 to go to main menu): ");
                    strNum = GetInt();
                    if (Convert.ToBoolean(strNum))
                    {
                        curText.RemoveString(strNum);
                    }
                    else
                    {
                        choise = -1;
                    }
                    break;

                case (3):
                    curText.Clear();
                    choise = -1;
                    break;

                case (4):
                    curText = curText.TextUpperCase();
                    choise  = -1;
                    break;

                case (5):
                    Console.Write("\nType a number of string (0 to go to main menu): ");
                    strNum = GetInt();
                    if (Convert.ToBoolean(strNum))
                    {
                        Console.Write("\nKeyWord: ");
                        curText[strNum - 1].KeyWord().WriteLine();
                        Console.ReadKey();
                    }
                    else
                    {
                        choise = -1;
                    }
                    break;

                case (6):
                    Console.Write("\nType a length (0 to go to main menu): ");
                    strNum = GetInt();
                    if (Convert.ToBoolean(strNum))
                    {
                        Console.Write("\nNumber of strings of a given length: {0}", curText.GetNumberOfStrings(strNum));
                        Console.ReadKey();
                    }
                    else
                    {
                        choise = -1;
                    }
                    break;

                case (0):
                    System.Environment.Exit(0);
                    break;

                default:
                    Console.WriteLine();
                    menu.WriteLine();
                    Console.WriteLine();
                    Console.Write("Choose a num from 0 to 6: ");
                    choise = GetInt();
                    break;
                }
                Console.Clear();
            }
        }