Example #1
0
        public void Appearance()
        {
        Dog d1 = new Dog();
        Console.WriteLine("Выберите цвет шерсти: \n");

        string [] hair = new string [3];
        hair[0] = "Рыжий";
        hair[1] = "Черный";
        hair[2] = "Белый \n";
        foreach (string i in hair)
        {
            Console.WriteLine(i);
        }

        string s = Console.ReadLine();
        d1.HairColor = s;

        Console.WriteLine("Выбран цвет шерсти:" + " " + d1.HairColor + "\n \n");

        Dog d2 = new Dog();
        Console.WriteLine("Выберите длину шерсти: \n \n");

        string [] length = new string [3];
        length[0] = "Короткая";
        length[1] = "Средняя";
        length[2] = "Длинная \n";
        foreach (string h in length)
        {
            Console.WriteLine(h);
        }

        string u = Console.ReadLine();
        d2.HairLength = u;

        Console.WriteLine("Выбрана длина шерсти:" + " " + d2.HairLength + "\n");
        Console.WriteLine("Для возврата в основное меню нажмите Enter \n");
        Console.ReadLine();
        Menu();
        }      
Example #2
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Black;
            Console.BackgroundColor = ConsoleColor.Yellow;
            Console.WriteLine(" \t \t \t Добро пожаловать!");
            //меню
            Console.ForegroundColor = ConsoleColor.Green;
            Console.BackgroundColor = ConsoleColor.Black;
            Console.WriteLine(" \t \t \t ------МЕНЮ------- \t \t \t \n");

            Console.WriteLine("\t Выберите персонажа: \n 1 - Собака \n 2 - Кошка \n 3 - Человек \n 4 - Выход");
            Console.ForegroundColor = ConsoleColor.White;

            string [] species = new string [3];
            species[0] = "Собака";
            species[1] = "Кот";
            species[2] = "Человек";

            DateTime curDate = DateTime.Now;
            Console.WriteLine("Введите номер выбора \n");
            int input = Convert.ToInt32(Console.ReadLine());

            CreatureName nm = new CreatureName();                       // реализация свойства
            Console.WriteLine("Выберите имя для персонажа \n");             
            string n = Console.ReadLine();
            nm.Name = n;
            
            

            if (input == 1)
            {
                Console.WriteLine("Поздравляем! Вы завели питомца: " + (species[0]) + " " + "по имени " + " " + nm.Name + ". \n" + "Дата и время создания: " + curDate);
            }
            else if (input == 2)
            {
                Console.WriteLine("Поздравляем! Вы завели питомца: " + (species[1]) + " " + "по имени " + " " + nm.Name + ". \n" + "Дата и время создания: " + curDate);
            }
            else
            {
                Console.WriteLine("Поздравляем! Вы завели питомца: " + (species[2]) + " " + "по имени " + " " + nm.Name + ". \n" + "Дата и время создания: " + curDate + " \n ");
            }


        link: try
            {
            switch (input)
                 {
                    case 1:
                         Dog dg = new Dog();
                         dg.Menu();
                         break;
                    case 2:
                         Cat ct = new Cat();
                         ct.Menu();
                         break;
                    case 3:
                         Human hm = new Human();
                         hm.Menu();
                         break;
                    case 4: 
                         goto link;
                 }

             }

            catch (FormatException)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Читай внимательно! Надо вводить Ч-И-С-Л-О!");
                Console.ForegroundColor = ConsoleColor.White;
                goto link;
            }
            catch (input > 3)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Надо вводить число от 1 до 3");
                goto link;
            }

        Console.ReadLine();
          
        }
Example #3
0
        public void Menu()
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.BackgroundColor = ConsoleColor.Black;
            Console.WriteLine(" \t \t \t ------МЕНЮ------- \t \t \t \n");
            Console.WriteLine("\t Выберите действие: \n 1 - Кормить \n 2 - Играть \n 3 - Спать \n 4 - Гулять \n 5 - Выбрать внешность \n 6 - Выбрать породу \n 7 - Выход");

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Введите номер выбора");
            int input = Convert.ToInt32(Console.ReadLine());

        link: try
            {
                switch (input)
                {
                    case 1:                         // дописать как-то меню 0_о
                        Dog d1 = new Dog();
                        d1.Feed();
                        break;
                    case 2:
                        Dog   d2 = new Dog();
                        d2.Play();
                        break;
                    case 3:
                        Dog d3 = new Dog();
                        d3.Sleep();
                        break;
                    case 4:
                        Dog d4 = new Dog();
                        d4.Walk();
                        break;
                    case 5:
                        Dog d5 = new Dog();
                        d5.Appearance();
                        break;
                    case 6:
                        Dog d6 = new Dog();
                        d6.Breed();
                        break;
                    case 7:
                        return;                      
                }
            }
            catch (FormatException)
            {
                Console.WriteLine("Читай внимательно! Надо вводить Ч-И-С-Л-О!");
                goto link;
            }   
        

                if (input < 1  || input > 7)
                { try
                {
                   Console.WriteLine("Проверьте введенное число!");
                   goto link;
                }
                   catch (FormatException)
                        {
                            Console.WriteLine("Число должно быть от 1 до 7");
                            goto link;
                        }
                }
        }