Example #1
0
        public MasivZ UpperToLower()
        {
            MasivZ newArr = new MasivZ();
            char   temp   = ' ';

            foreach (var symb in Symbols)
            {
                if (char.IsLower(symb))
                {
                    temp = char.ToUpper(symb);
                    newArr.Symbols.Add(temp);
                    newArr.Codes.Add((int)temp);
                }
                else
                {
                    if (char.IsUpper(symb))
                    {
                        temp = char.ToLower(symb);
                        newArr.Symbols.Add(temp);
                        newArr.Codes.Add((int)temp);
                    }

                    else
                    {
                        newArr.Symbols.Add(symb);
                        newArr.Codes.Add((int)symb);
                    }
                }
            }
            return(newArr);
        }
Example #2
0
        public static void WriteArray(MasivZ arr, string path)
        {
            List <char> tempSymb  = arr.Symbols;
            List <int>  tempCodes = arr.Codes;

            tempSymb.RemoveAll(x => (int)x < 32);
            tempCodes.RemoveAll(x => x < 32);
            WriteArray(tempSymb, path);
            WriteArray(tempCodes, path);
        }
Example #3
0
        public static void PrintMasivZ(MasivZ arr, Iinterface ui)
        {
            foreach (var symb in arr.Symbols)
            {
                ui.Write(symb + " ");
            }

            ui.Write("\n");

            foreach (var code in arr.Codes)
            {
                ui.Write(code + " ");
            }
            ui.Write("\n");
        }
Example #4
0
        public static MasivZ ReadMasivZ(string path)
        {
            MasivZ arr = new MasivZ();

            using (StreamReader reader = new StreamReader(path))
            {
                for (int i = 0; i < currentRow * 2; ++i)
                {
                    reader.ReadLine();
                }
                arr.Symbols = reader.ReadLine().ToList <char>().Where((x, i) => i % 2 == 0).ToList();
                arr.Codes   = reader.ReadLine().Split().Where(x => x != "").Select(x => int.Parse(x.ToString())).ToList();
                ++currentRow;
            }
            return(arr);
        }
Example #5
0
        public void Run()
        {
            int        N     = 0;
            List <int> arr   = new List <int>();
            MasivZ     arrZ  = new MasivZ();
            string     path1 = "";
            string     path2 = "";
            string     path3 = "";

            UserInterface.Write("Input N \n");
            try
            {
                N            = int.Parse(UserInterface.Read());
                arr.Capacity = N;

                ArrayEditor.FillArr(arr);


                UserInterface.Write("input name of file (without extension) \n");
                path1 = @"..\..\..\Mas\" + UserInterface.Read() + ".txt";

                ArrayIO.WriteArray(arr, path1);

                List <List <int> > arrB = ArrayEditor.ConvertToTwoRank(ArrayIO.ReadArray(path1));

                UserInterface.Write("input name of file (without extension) \n");
                path2 = @"..\..\..\Mas\" + UserInterface.Read() + ".txt";

                ArrayIO.WriteArray(arrB, path2);

                arrZ.CreateFromIntArray(arrB);

                MasivZ arrC = arrZ.UpperToLower();

                UserInterface.Write("input name of file (without extension) \n");
                path3 = @"..\..\..\Mas\" + UserInterface.Read() + ".txt";

                ArrayIO.WriteArray(arrZ, path3);
                ArrayIO.WriteArray(arrC, path3);

                MasivZ tempZ = ArrayIO.ReadMasivZ(path3);
                MasivZ tempC = ArrayIO.ReadMasivZ(path3);
                UserInterface.Write("Arrays Z and C without escape sequences(start ascii code is 32)\n");
                UserInterface.Write("\nArray C\n");

                ArrayIO.PrintMasivZ(tempC, UserInterface);
                UserInterface.Write("\nArray Z\n");
                ArrayIO.PrintMasivZ(tempZ, UserInterface);

                DirectoryInfo dir = new DirectoryInfo(@"..\..\..\Mas");

                dir.PrintListOfFiles(UserInterface);

                var files = dir.GetFiles();

                var lastTime = files.Select(x => x.CreationTime).Max();
                files.First(x => x.CreationTime == lastTime).MoveTo(@"..\..\..\Mas\newName.txt");

                UserInterface.Write("\nLast creation file was renamed to newName.txt\nNew list of files: \n");
                dir.PrintListOfFiles(UserInterface);
            }
            catch
            { throw new Exception("очепятка"); }
        }