Exemplo n.º 1
0
        public void Appearance()
        {
            Cat c1 = new Cat();
            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();
            c1.HairColor = s;

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

            Cat c2 = new Cat();
            Console.WriteLine("Выберите длину шерсти: \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();
            c2.HairLength = u;

            Console.WriteLine("Выбрана длина шерсти:" + " " + c2.HairLength + "\n");
            Console.WriteLine("Для возврата в основное меню нажмите Enter \n");
            Console.ReadLine();
            Menu();
        }
Exemplo n.º 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();
          
        }
Exemplo n.º 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 \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:                         
                        Cat c1 = new Cat();
                        c1.Feed();
                        break;
                    case 2:
                        Cat c2 = new Cat();
                        c2.Play();
                        break;
                    case 3:
                        Cat c3 = new Cat();
                        c3.Sleep();
                        break;
                    case 4:
                        Cat c4 = new Cat();
                        c4.Walk();
                        break;
                    case 5:
                        Cat c5 = new Cat();
                        c5.Appearance();
                        break;
                    case 6:
                        Cat c6 = new Cat();
                        c6.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;
                        }
                }
        }