Exemplo n.º 1
0
 static void Main(string[] args)
 {
     do
     {
         int n;
         try
         {
             n = int.Parse(Console.ReadLine());
             MyString[] arr = new MyString[2];
             arr[0] = new LatString(n, 'a', 'z');
             arr[1] = new RusString(n, 'а', 'я');
             Console.WriteLine(arr[0].Str);
             Console.WriteLine(arr[1].Str);
             Console.WriteLine(arr[0].IsPalindrome());
             Console.WriteLine(arr[1].IsPalindrome());
             Console.WriteLine(((RusString)(arr[1])).CountLetter('а'));
             Console.WriteLine("enter size");
         } catch (ArgumentOutOfRangeException ex) {
             Console.WriteLine(ex.Message);
             continue;
         } catch (FormatException ex) {
             Console.WriteLine(ex.Message);
             continue;
         }
         Console.WriteLine("To exit press escape");
     } while (Console.ReadKey().Key != ConsoleKey.Escape);
 }
Exemplo n.º 2
0
    //send a player's landmark to database, status : unlimited, no duplicates locations
    public void sendlandmark()
    {
        Debug.Log("sendlandmarks called");
        WWWForm form = new WWWForm();

        //check if name is not empty and less than 16
        if (NameString.text != "" && NameString.text.Length < 16)
        {
            if (LatString.text != "" && LonString.text != "")
            {
                form.AddField("Name", NameString.GetComponent <Text>().text);
                form.AddField("PlayerID", Player.playername);
                form.AddField("Lon", LonString.GetComponent <Text>().text);
                form.AddField("Lat", LatString.GetComponent <Text>().text);
                WWW uploadLandmark = new WWW(url, form);
                StartCoroutine(WaitForRequest(uploadLandmark));
            }
            else
            {
                debug.text = "Location services must be on to work.";
            }
        }
        else
        {
            debug.text = "Name cannot be blank or more than 16 characters";
        }
    }
        static void Main(string[] args)
        {
            char start = 'к', finish = 'ю';

            do
            {
                RusString testRusString = new RusString(start, finish, 10);
                LatString testLatString = new LatString(start, finish, 10);
                Console.WriteLine(testRusString);
                Console.WriteLine(testRusString.CountLetter('о'));
                // тестируем неверные входные данные
                try
                {
                    testRusString = new RusString(start, finish, -11);
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    Console.WriteLine("Состояние объекта не изменено");// если объект не сформирован
                    Console.WriteLine(ex.Message);
                }
                Console.WriteLine(testLatString);
                Console.WriteLine(testLatString.CountLetter('o'));
                // тестируем неверные входные данные
                try
                {
                    testLatString = new LatString(start, finish, -11);
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    Console.WriteLine("Состояние объекта не изменено");// если объект не сформирован
                    Console.WriteLine(ex.Message);
                }
            } while (Console.ReadKey().Key != ConsoleKey.Escape);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            char start = 'к', finish = 'ю';

            do
            {
                MyStrings testString  = new RusString(start, finish, 10);
                MyStrings testString1 = new LatString('a', 'q', 7);
                Console.WriteLine(testString);
                Console.WriteLine(testString.CountLetter('о'));
                Console.WriteLine(testString1);
                Console.WriteLine(testString1.CountLetter('b'));
                // тестируем неверные входные данные
                try
                {
                    testString = new RusString(start, finish, -11);
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    Console.WriteLine("Состояние объекта не изменено");// если объект не сформирован
                }
                try
                {
                    testString1 = new LatString('6', 'x', 6);
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    Console.WriteLine("Состояние объекта не изменено");// если объект не сформирован
                }
                Console.WriteLine(testString);
                Console.WriteLine(testString.CountLetter('о'));
                Console.WriteLine(testString1);
                Console.WriteLine(testString1.CountLetter('j'));
            } while (Console.ReadKey().Key != ConsoleKey.Escape);
        }
Exemplo n.º 5
0
    public void sendlandmark()
    {
        Debug.Log("sendlandmarks called");
        WWWForm form = new WWWForm();

        //check if name is not empty and less than 16
        if (NameString.text != "" && NameString.text.Length < 16)
        {
            if (LatString.text != "" && LonString.text != "")
            {
                form.AddField("NameFromUnity", NameString.GetComponent <Text>().text);
                form.AddField("LonFromUnity", LonString.GetComponent <Text>().text);
                form.AddField("LatFromUnity", LatString.GetComponent <Text>().text);
                WWW upload = new WWW(url, form);
                // yield return download;
                //Debug.Log(download.error);
                if (!string.IsNullOrEmpty(upload.error))
                {
                    print(upload.error);
                }
                else
                {
                    print("Finished Uploading Landmark");
                }
            }
            else
            {
                debug.text = "Lat/Lon not set. Location must be on to work.";
            }
        }
        else
        {
            debug.text = "Name cannot be blank or more than 16 characters";
        }
    }
        static void Main(string[] args)
        {
            char start  = 'к',
                 finish = 'ю';

            do
            {
                MyStrings testString = new RusString(start, finish, 10);
                Console.WriteLine(testString);
                Console.WriteLine(testString.CountLetter('o'));

                // Тестируем.
                try
                {
                    testString = new RusString(start, finish, -11);
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    Console.WriteLine("Ошибка:" + ex.Message);
                    Console.WriteLine("Состояние объекта не изменено");
                }

                Console.WriteLine(testString);
                Console.WriteLine(testString.CountLetter('o'));
            }while (Console.ReadKey().Key != ConsoleKey.Escape);

            // Теперь тестируем класс для латинских строк.
            start  = 'f';
            finish = 'l';
            Console.WriteLine("\n");
            do
            {
                MyStrings testString = new LatString(start, finish, 10);
                Console.WriteLine(testString);
                Console.WriteLine(testString.CountLetter('h'));

                // Тестируем.
                try
                {
                    testString = new RusString(start, finish, -11);
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    Console.WriteLine("Ошибка:" + ex.Message);
                    Console.WriteLine("Состояние объекта не изменено");
                }

                Console.WriteLine(testString);
                Console.WriteLine(testString.CountLetter('h'));
            }while (Console.ReadKey().Key != ConsoleKey.Escape);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            char start = 'к', finish = 'ю';

            do
            {
                MyStrings testString = new RusString(start, finish, 10);

                Console.WriteLine(testString);
                Console.WriteLine(testString.CountLetter('о'));
                Console.WriteLine(testString.IsPalidrome());

                try
                {
                    testString = new RusString(start, finish, -11);
                }
                catch (ArgumentOutOfRangeException)
                {
                    Console.WriteLine("Nothing was changed.");
                }

                Console.WriteLine(testString);
                Console.WriteLine(testString.CountLetter('о'));
                Console.WriteLine(testString.IsPalidrome());

                testString = new LatString(start, finish, 10);

                Console.WriteLine(testString);
                Console.WriteLine(testString.CountLetter('о'));
                Console.WriteLine(testString.IsPalidrome());

                try
                {
                    testString = new RusString(start, finish, -11);
                }
                catch (ArgumentOutOfRangeException)
                {
                    Console.WriteLine("Nothing was changed.");
                }

                Console.WriteLine(testString);
                Console.WriteLine(testString.CountLetter('о'));
                Console.WriteLine(testString.IsPalidrome());
            } while (Console.ReadKey().Key != ConsoleKey.Escape);
        }
        static void Main(string[] args)
        {
            do
            {
                char start1, finish1, start2, finish2;
                do
                {
                    Console.Clear();
                    try
                    {
                        Console.WriteLine("Введите русские символы(начало и конец)");
                        start1  = Console.ReadKey().KeyChar;
                        finish1 = Console.ReadKey().KeyChar;
                        Console.WriteLine();
                        Console.WriteLine("Введите латинские символы(начало и конец)");
                        start2  = Console.ReadKey().KeyChar;
                        finish2 = Console.ReadKey().KeyChar;
                        break;
                    }
                    catch (ArgumentOutOfRangeException ex)
                    {
                        Console.WriteLine("Введены неверные значения");
                    }
                } while (true);
                try
                {
                    MyStrings testString1 = new RusString(start1, finish1, 10);
                    MyStrings testString2 = new LatString(start2, finish2, 23);

                    Console.WriteLine("Для ру слов");

                    // тестируем неверные входные данные
                    try
                    {
                        Console.WriteLine(testString1);
                        Console.WriteLine(testString1.CountLetter('о'));
                        testString1 = new RusString(start1, start1, -11);
                    }
                    catch (ArgumentOutOfRangeException ex)
                    {
                        Console.WriteLine("Состояние объекта не изменено");// если объект не сформирован
                    }
                    catch (OverflowException ex)
                    {
                        Console.WriteLine("За массив выходим :(");
                    }

                    Console.WriteLine("Для лат слов");
                    // тестируем неверные входные данные
                    try
                    {
                        Console.WriteLine(testString2);
                        Console.WriteLine(testString2.CountLetter('о'));
                        testString2 = new RusString(start2, start2, -11);
                    }
                    catch (ArgumentOutOfRangeException ex)
                    {
                        Console.WriteLine("Состояние объекта не изменено");// если объект не сформирован
                    }
                    catch (OverflowException ex)
                    {
                        Console.WriteLine("За массив выходим :(");
                    }
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    Console.WriteLine("Введеные неверные значения");
                }
            } while (Console.ReadKey().Key != ConsoleKey.Escape);
        }