Beispiel #1
0
        public static myString operator *(myString var, char c)
        {
            myString temp = new myString();

            for (int i = 0; i < var.length; i++)
            {
                temp.str[i] = c;
            }
            temp.length = var.length;

            return(temp);
        }
Beispiel #2
0
 public int Compare(myString a)
 {
     if (this.length < a.length)
     {
         return(-1);
     }
     else if (this.length == a.length)
     {
         return(0);
     }
     else
     {
         return(1);
     }
 }
Beispiel #3
0
        public static bool CheckForSymbols(this myString str, string checkStr)
        {
            for (int i = 0; i < str.Length; i++)
            {
                for (int j = 0; j < checkStr.Length; j++)
                {
                    if (str.Str[i] == checkStr[j])
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #4
0
        public myString DeleteLastEl()
        {
            myString temp = new myString();

            for (int i = 0; i < this.length - 1; i++)
            {
                temp.str[i] = this.str[i];
            }

            temp.length = this.length - 1;

            this.str[this.length - 1] = '\0';
            this.length--;

            return(temp);
        }
Beispiel #5
0
        public static void DeletePunctuationMarks(this myString str)
        {
            char[] temp = new char[str.Length];
            for (int i = 0, j = 0; i < str.Length; i++)
            {
                if (str.Str[i] != ',' && str.Str[i] != '.' && str.Str[i] != '!' && str.Str[i] != '?' && str.Str[i] != ';' && str.Str[i] != ':' && str.Str[i] != '-')
                {
                    temp[j++] = str.Str[i];
                }
                else
                {
                    str.Length--;
                }
            }

            str.Str = temp;
        }
Beispiel #6
0
        public static myString Concat(this myString str1, myString str2)
        {
            myString temp = new myString();
            int      i    = 0;

            for (; i < str1.Length; i++)
            {
                temp.Str[i] = str1.Str[i];
            }

            for (int j = 0; j < str2.Length; j++)
            {
                temp.Str[i++] = str2.Str[j];
            }

            temp.Length = i + 1;

            return(temp);
        }
Beispiel #7
0
        public static myString operator +(myString var, int i)
        {
            myString temp = new myString();

            for (int j = 0; j < var.length; j++)
            {
                temp.str[j] = var.str[j];
            }
            temp.length = var.length;

            string tempStr = i.ToString();

            for (int k = temp.length, j = 0; j < tempStr.Length; k++, j++)
            {
                temp.str[k] = tempStr[j];
                temp.length++;
            }

            return(temp);
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            myString a = new myString("Hello");
            myString b = new myString();

            Console.WriteLine(" владелец:  " + a.infAboutCreator.name + "  организация:  " + a.infAboutCreator.organization + " дата и время создания:  " + a.creationTime.time);

            for (int j = 0; j < a.Length; j++)
            {
                Console.WriteLine(a[j]);
            }
            Console.Write("Удалить последний элемент\n");


            b = a.DeleteLastEl();
            for (int j = 0; j < b.Length; j++)
            {
                Console.WriteLine(b[j]);
            }
            Console.Write("добавить к строке число \n");


            b = a + 421;
            for (int j = 0; j < b.Length; j++)
            {
                Console.WriteLine(b[j]);
            }
            Console.Write("сравнить строки\n");


            if (a.Compare(b) == -1 && a < b)
            {
                Console.WriteLine('<');
            }
            else if (a.Compare(b) == 0 && a == b)
            {
                Console.WriteLine('=');
            }
            else
            {
                Console.WriteLine('>');
            }
            Console.Write("заменить всё введенным символом\n");


            b = a * '!';
            for (int j = 0; j < b.Length; j++)
            {
                Console.WriteLine(b[j]);
            }
            b[0] = a[0];
            Console.Write("содержатся ли символы?\n");


            if (a.CheckForSymbols("abc!"))
            {
                Console.WriteLine(true);
            }
            else
            {
                Console.WriteLine(false);
            }
            Console.Write("строка с запятой\n");


            a    = a + 123456;
            a[3] = ',';
            for (int j = 0; j < a.Length; j++)
            {
                Console.WriteLine(a[j]);
            }
            Console.Write("удалили знаки препинания\n");


            a.DeletePunctuationMarks();
            for (int j = 0; j < a.Length; j++)
            {
                Console.WriteLine(a[j]);
            }
            Console.Write("объединили строки\n");


            a.Concat(b);
            for (int j = 0; j < a.Length; j++)
            {
                Console.WriteLine(a[j]);
            }
        }
Beispiel #9
0
 public static int Elcounter(this myString str)
 {
     return(str.Length);
 }
Beispiel #10
0
 public static int DiffBetweenStrs(this myString str1, myString str2)
 {
     return(Math.Abs(str1.Length - str2.Length));
 }
Beispiel #11
0
        static void Main(string[] args)
        {
            myString a = new myString("Hello");
            myString b = new myString();

            for (int j = 0; j < a.Length; j++)
            {
                Console.WriteLine(a[j]);
            }
            Console.Write("----------------------------------------------------------------------------------------------------------\n");


            b = a.DeleteLastEl();
            for (int j = 0; j < b.Length; j++)
            {
                Console.WriteLine(b[j]);
            }
            Console.Write("----------------------------------------------------------------------------------------------------------\n");


            b = a + 421;
            for (int j = 0; j < b.Length; j++)
            {
                Console.WriteLine(b[j]);
            }
            Console.Write("----------------------------------------------------------------------------------------------------------\n");


            if (a.Compare(b) == -1 && a < b)
            {
                Console.WriteLine('<');
            }
            else if (a.Compare(b) == 0 && a == b)
            {
                Console.WriteLine('=');
            }
            else
            {
                Console.WriteLine('>');
            }
            Console.Write("----------------------------------------------------------------------------------------------------------\n");


            b = a * '!';
            for (int j = 0; j < b.Length; j++)
            {
                Console.WriteLine(b[j]);
            }
            b[0] = a[0];
            Console.Write("----------------------------------------------------------------------------------------------------------\n");


            if (a.CheckForSymbols("abc!"))
            {
                Console.WriteLine(true);
            }
            else
            {
                Console.WriteLine(false);
            }
            Console.Write("----------------------------------------------------------------------------------------------------------\n");


            a    = a + 123456;
            a[3] = ',';
            for (int j = 0; j < a.Length; j++)
            {
                Console.WriteLine(a[j]);
            }
            Console.Write("----------------------------------------------------------------------------------------------------------\n");


            a.DeletePunctuationMarks();
            for (int j = 0; j < a.Length; j++)
            {
                Console.WriteLine(a[j]);
            }
            Console.Write("----------------------------------------------------------------------------------------------------------\n");


            a.Concat(b);
            for (int j = 0; j < a.Length; j++)
            {
                Console.WriteLine(a[j]);
            }
        }