Пример #1
0
        static void Main(string[] args)
        {
            int age, figure;
            try
            {
                Console.WriteLine("Введите возраст кошки не больше 20");
                age = int.Parse(Console.ReadLine());
            }
            catch (FormatException)
            {
                Console.WriteLine("Кошки столько не живут, введите заново");
                return;
            }

            Cat cat1 = new Cat(age); //вызов конструктора
            while (true)
            {
                Console.WriteLine("Cat's age is " + cat1.Age);
                Console.WriteLine("Cat's name is " + cat1.Name);
                Console.WriteLine("Cat's color is " + cat1.CurrentColor);
                Console.WriteLine();
                Console.WriteLine("Menu");
                Console.WriteLine("1. Set name");
                Console.WriteLine("2. Change a color");
                Console.WriteLine("3. Punish");
                Console.WriteLine("4. Feed");
                Console.WriteLine();
                Console.WriteLine("Type a needed figure without dot and push Enter");
                figure = Convert.ToInt32(Console.ReadLine());
                if (figure == 0)
                {
                    try
                    {
                        Console.WriteLine("Type cat's name, please");
                        cat1.Name = Console.ReadLine();
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(exc.Message);
                    }
                }
                else if (figure == 1)
                {
                    Console.WriteLine("Type a color of healthy cat");
                    cat1.CatColor.HealthyColor = Console.ReadLine();
                    Console.WriteLine("Type a color of sick cat");
                    cat1.CatColor.SickColor = Console.ReadLine();
                }
                else if (figure == 2)
                {
                    cat1.Punish();
                }
                else if (figure == 3)
                {
                    cat1.Feed();
                }

            }
        }
Пример #2
0
 public static void ChangeCatColor(Model.Cat cat, CatColor color)
 {
     Console.WriteLine("Задайте цвет здоровой кошки: ");
     color.HealtyColor = Console.ReadLine();
     Console.WriteLine("Задайте цвет больной кошки: ");
     color.SickColor = Console.ReadLine();
     cat.Color       = color;
 }
Пример #3
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Приветствуем Вас в нашем Зоомагазине!");
            Console.WriteLine("Укажите возраст питомца:");
            var colour = new CatColour("Белый", "Зеленый");
            var myLittleKitty = new Cat(colour, Console.ReadLine());
            int cls = 0;
            while (cls != 5)
            {
                if (myLittleKitty.CurrentColour == colour.HealthColour)
                {
                    Helper.ChangeConsoleColour(myLittleKitty.CurrentColour, 1);
                }
                else
                {
                    Helper.ChangeConsoleColour(myLittleKitty.CurrentColour, 0);
                }
                Console.WriteLine($"Питомец:{myLittleKitty.Name}");
                Console.WriteLine($"Возраст:{myLittleKitty.Age}");
                Console.WriteLine($"Текущий цвет:{myLittleKitty.CurrentColour}");

                Console.WriteLine("1 - Задать имя;" + "\n" + "2 - Задать цвет;" + "\n" + "3 - Покормить;" + "\n" +
                                  "4 - Ударить;" + "\n" + "5 - Выход;");

                cls = Convert.ToInt32((Console.ReadLine()));
                switch (cls)
                {
                    case 1:
                      Console.WriteLine("Введите имя питомца:");
                      myLittleKitty.Name = Console.ReadLine();
                        break;

                    case 2:
                        Console.WriteLine("Доступные цвета:" + "\n" + "Ж - Жёлтый;" + "\n" + "К - Красный;" + "\n" +
                                          "С - Синий;" + "\n" + "П - Пурпурный;" + "\n" + "Б - Белый;" + "\n" +
                                          "З - Зелёный;" + "\n");

                        Console.WriteLine("Желаемый цвет здорового кота:");
                        myLittleKitty.Colour.HealthColour = Console.ReadLine();
                        Console.WriteLine("Цвет кота в болезненном состоянии:");
                        myLittleKitty.Colour.SickColour = Console.ReadLine();
                        break;

                    case 3:
                    myLittleKitty.Feed();
                        break;

                    case 4:
                        myLittleKitty.Punish();
                        break;

                    case 5:
                    break;

                }
               }
        }
Пример #4
0
 public static void PrintMenu(Model.Cat cat)
 {
     Console.WriteLine("Выберите действие и введите его номер");
     Console.WriteLine("1. Покормить кошку");
     Console.WriteLine("2. Наказать кошку");
     Console.WriteLine("3. Изменить цвет кошки");
     if (cat.Name == null)
     {
         Console.WriteLine("4. Дать кошке имя");
     }
 }
Пример #5
0
 private void btnBuy_Click(object sender, EventArgs e)
 {
     if (tbAge.Text == "") return;
     _cat = new Cat(tbAge.Text);
     gbBuy.Enabled = false;
     groupBox2.Enabled = true;
     gbDye.Enabled = true;
     btnFeed.Enabled = true;
     btnPunish.Enabled = true;
     Reload();
 }
Пример #6
0
 public static void PrintInfo(Model.Cat cat, Model.CatColor color)
 {
     if (cat.Name != null)
     {
         Console.WriteLine("Имя кошки: ");
         Console.WriteLine(cat.Name);
     }
     Console.WriteLine("Возраст кошки: ");
     Console.WriteLine(cat.Age);
     Console.WriteLine("Текущий цвет кошки");
     Console.WriteLine(cat.CurrentColor);
 }
Пример #7
0
 static void Main(string[] args)
 {
     Console.Title = "Cat";
     Console.Write("Введите возраст: ");
     var age = Console.ReadLine();
     var catColor = new CatColor()
     {
         SickColor = "Зеленый",
         HealthyColor = "Белый"
     };
     var newCat = new Cat(age, catColor);
     while (true)
     {
         Console.Clear();
         Console.WriteLine("Имя {0}\nВозраст {1}\nТекущий цвет {2}", newCat.Name, age, newCat.CurrentColor);
         Console.WriteLine("1. Задать имя\n2. Задать цвет\n3. Ударить\n4. Покормить");
         try
         {
             switch (Int32.Parse(Console.ReadLine()))
             {
                 case 1:
                     Console.Write("\nВведите имя: ");
                     newCat.Name = Console.ReadLine();
                     break;
                 case 2:
                     Console.Write("Введите цвет больной кошки: ");
                     newCat.Color.SickColor = Console.ReadLine();
                     Console.Write("Введите цвет здоровой кошки: ");
                     newCat.Color.HealthyColor = Console.ReadLine();
                     break;
                 case 3:
                     Console.Write("Вы наказали кошку");
                     newCat.Punish();
                     Console.ReadKey();
                     break;
                 case 4:
                     Console.WriteLine("Вы покормили кошку");
                     newCat.Feed();
                     Console.ReadKey();
                     break;
                 default:
                     Console.WriteLine("Неправильный пункт меню");
                     Console.ReadKey();
                     break;
             }
         }
         catch (Exception)
         {
             Console.WriteLine("Ошибка");
             Console.ReadKey();
         }
     }
 }
Пример #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("Задайте возраст кошки: ");
            string age = Console.ReadLine();

            Console.WriteLine("Цвет кошки задан по умолчанию. Здоровая кошка - белая, больная - зеленая. Здоровье кошки изменяется в зависимости от ухода.");
            Console.WriteLine("Если Вы хотите изменить цвет кошки, введите 1, иначе - введите любое другое число");
            var color = new CatColor();

            if (Console.ReadLine() == "1")
            {
                Console.WriteLine("Задайте цвет здоровой кошки: ");
                color.HealtyColor = Console.ReadLine();
                Console.WriteLine("Задайте цвет больной кошки: ");
                color.SickColor = Console.ReadLine();
            }
            else
            {
                color.SickColor   = "зелёный";
                color.HealtyColor = "белый";
            }
            var cat = new Model.Cat(age, 5, color);

            while (true)
            {
                PrintInfo(cat, color);
                PrintMenu(cat);
                int menu = Convert.ToInt32(Console.ReadLine());
                if (menu == 1)
                {
                    cat.Feed();
                }
                else if (menu == 2)
                {
                    cat.Punish();
                }
                else if (menu == 3)
                {
                    ChangeCatColor(cat, color);
                }
                else if (menu == 4)
                {
                    Console.WriteLine("Введите имя для кошки (имя можно задать только один раз):");
                    cat.Name = Console.ReadLine();
                }
                else
                {
                    Console.WriteLine("Введено некорректное значение! Попробуйте ещё раз");
                }
            }
        }
Пример #9
0
        private static void Main(string[] args)
        {
            Console.WriteLine("\tCat for programmer");
            Console.WriteLine("Enter the Cat age");
            var cat = new Cat(Console.ReadLine());
            var catColor = new CatColor();
            string menu = "";
            do
            {
                Console.Write("Cat`s Age: {0}\nCat`s name: {1}\nCat`s Color: {2}", cat.Age, cat.Name, cat.CurrentColor);
                Console.WriteLine();
                Console.WriteLine("a. Set Health and Sick color\nb. Feed the Cat\nc. Punish the Cat\nd. Name the Cat\n");
                menu = Console.ReadLine();
                switch (menu)
                {

                    case "a":
                    {
                        Console.WriteLine("Sick color:");
                        cat.Color.SickColor = Console.ReadLine();
                        Console.WriteLine("Healthy color:");
                        cat.Color.HealthyColor = Console.ReadLine();
                        break;
                    }
                    case "b":
                    {
                        cat.Feed();
                        break;
                    }
                    case "c":
                    {
                        cat.Punish();
                        break;
                    }
                    case "d":
                    {
                        Console.WriteLine("Enter the name");
                        cat.Name = Console.ReadLine();
                        break;
                    }

                }
                Console.Clear();

            } while (true);
        }
Пример #10
0
        private static void Main(string[] args)
        {
            var color = new CatColor();
            string age;

            Console.WriteLine("Вы купили кошку!");

            Console.Write("Введите возраст кошки: ");
            age = Console.ReadLine();

            var cat = new Cat(color, age);

            int i;
            do
            {
                Console.WriteLine("\nТекущая информация о кошке: \nИмя: " + cat.Name + "\nВозраст: " + cat.Age + "\nТекущий цвет: " + cat.CurrentColor);

                Console.Write("\n\nМеню: \n1)Дать кошке имя \n2) Изменить цвет здоровой кошки \n3) Изменить цвет больной кошки \n4) Наказать \n5) Покормить \n6) Выйти \n\nВаше решение: ");

                i = int.Parse(Console.ReadLine());
                switch (i)
                {
                    case 1:
                        Console.Write("Введите имя кошки: ");
                        cat.Name = Console.ReadLine();
                        break;
                    case 2:
                        Console.Write("Введите цвет здоровой кошки: ");
                        color.HealthyColor = Console.ReadLine();
                        break;
                    case 3:
                        Console.Write("Введите цвет больной кошки: ");
                        color.SickColor = Console.ReadLine();
                        break;
                    case 4:
                        cat.Punish();
                        break;
                    case 5:
                        cat.Feed();
                        break;
                    case 6:
                        break;
                }
            } while (i != 6);
        }
Пример #11
0
        static void Main(string[] args)
        {
            var color = new CatColor();
            string Age;

            Console.WriteLine("Вы купили кошку.\n");
            Console.WriteLine("Введите возраст кошки:");
            Age = Console.ReadLine();
            var cat = new Cat(color, Age);

            int caseSwitch;
            do
            {
                Console.Write("Возраст кошки: " + cat.Age + "\nИмя кошки: " + cat.Name + "\nЦвет кошки: " + cat.CurrentColor);
                Console.Write("\nМеню \n1.Выбрать имя кошки \n2.Выбрать цвет здоровой кошки. \n3.Выбрать цвет больной кошки. \n4.Покормить кошку. \n5.Наказать кошку. \n6.Выход\n");
                caseSwitch = int.Parse (Console.ReadLine());
                switch (caseSwitch)
                {
                    case 1:
                        Console.WriteLine("Введите имя кошки:\n");
                        cat.Name = Console.ReadLine();
                        break;
                    case 2:
                        Console.Write("Введите цвет здоровой кошки:\n");
                        color.HealthyColor = Console.ReadLine();
                        break;
                    case 3:
                        Console.Write("Введите цвет больной кошки:\n");
                        color.SickColor = Console.ReadLine();
                        break;
                    case 4:
                        cat.Feed();
                        break;
                    case 5:
                        cat.Punish();
                        break;
                    case 6:
                        break;
                }
            } while (caseSwitch != 6);
        }
Пример #12
0
 static void Main(string[] args)
 {
     Console.WriteLine("Задайте возраст кошки: ");
     string age = Console.ReadLine();
     Console.WriteLine("Цвет кошки задан по умолчанию. Здоровая кошка - белая, больная - зеленая. Здоровье кошки изменяется в зависимости от ухода.");
     Console.WriteLine("Если Вы хотите изменить цвет кошки, введите 1, иначе - введите любое другое число");
     var color = new CatColor();
     if (Console.ReadLine() == "1")
     {
         Console.WriteLine("Задайте цвет здоровой кошки: ");
         color.HealtyColor = Console.ReadLine();
         Console.WriteLine("Задайте цвет больной кошки: ");
         color.SickColor = Console.ReadLine();
     }
     else
     {
         color.SickColor  = "зелёный";
         color.HealtyColor = "белый";
     }
     var cat = new Model.Cat(age, 5, color);
     while (true)
     {
         PrintInfo(cat, color);
         PrintMenu(cat);
         int menu = Convert.ToInt32(Console.ReadLine());
             if (menu == 1)
                 cat.Feed();
             else if (menu == 2)
                 cat.Punish();
             else if (menu == 3)
                 ChangeCatColor(cat, color);
             else if (menu == 4)
             {
                Console.WriteLine("Введите имя для кошки (имя можно задать только один раз):");
                 cat.Name = Console.ReadLine();
             }
             else
                 Console.WriteLine("Введено некорректное значение! Попробуйте ещё раз");
         
     }
 }
Пример #13
0
 static void Main(string[] args)
 {
     int menu = 0;
     Console.WriteLine("Input age of cat");
     Cat cat = new Cat(Console.ReadLine());
 
     do
     {
         Console.WriteLine("\nName: {0}", cat.Name);
         Console.WriteLine("Age: {0}", cat.Age);
         Console.WriteLine("Current Color: {0}", cat.CurrentColor);
         Console.WriteLine();
         Console.WriteLine("1) Input name");
         Console.WriteLine("2) Change color");
         Console.WriteLine("3) Punish");
         Console.WriteLine("4) Feed");
         Console.WriteLine("5) Exit");
         menu = Convert.ToInt32(Console.ReadLine());
         switch (menu)
         {
             case 1:
                 cat.Name = Convert.ToString(Console.ReadLine());
                 break;
             case 2:
                 Console.WriteLine("Change current color of cat");
                 cat.CurrentColor = Convert.ToString(Console.ReadLine());
                 break;
             case 3:
                 cat.Punish();
                 break;
             case 4:
                 cat.Feed();
                 break;
         }
     } while (menu!=5); 
     Console.ReadKey();
 }
Пример #14
0
        static void Main(string[] args)
        {
            Console.Write("Возраст Вашей кошки: ");
            int age;
            age = Convert.ToInt32(Console.ReadLine());

            var cat = new Cat(age);

            Console.Clear();

            int a;

            do
            {
                Console.Clear();

                Console.Write("Имя: ");
                Console.WriteLine(cat.Name);
                Console.Write("Возраст: ");
                Console.WriteLine(cat.Age);
                Console.Write("Текущий цвет: ");
                Console.WriteLine(cat.CurrentColor);

                Console.WriteLine();

                Console.WriteLine("1-задать имя; 2-задать цвет; 3-ударить; 4-покормить; 0-выход");
                a = Convert.ToInt32(Console.ReadLine());
                if (a == 1)
                {
                    string name;
                    Console.Write("Введите имя кошки: ");
                    name = Console.ReadLine();
                    cat.Name = name;
                }
                else
                {
                    if (a == 2)
                    {
                        string healthycolor;
                        string sickcolor;
                        Console.Write("Введите цвет кошки в здоровом состоянии: ");
                        healthycolor = Console.ReadLine();
                        Console.Write("Введите цвет кошки в больном состоянии: ");
                        sickcolor = Console.ReadLine();
                        cat.Color = new CatColor(healthycolor, sickcolor);
                    }
                    else
                    {
                        if (a == 3)
                        {
                            cat.Punish();
                            Console.WriteLine("Кошка наказана");
                        }
                        else
                        if (a == 4)
                        {
                            cat.Feed();
                            Console.WriteLine("Кошка накормлена");
                        }

                    }
                    System.Threading.Thread.Sleep(1000);
                }
            } while (a != 0);
        }
Пример #15
0
        static void Main(string[] args)
        {
            var cat = new Cat();
            Console.WriteLine("Введите возраст питомца");
            cat.Age = Console.Read();


            for (;;)
            {
                Console.Clear();
                Console.WriteLine("1. Задать имя");
                Console.WriteLine("2. Изменить цвет");
                Console.WriteLine("3. Ударить");
                Console.WriteLine("4. Покормить");
                Console.WriteLine("5. Покинуть приложение");

                string menu = Console.ReadLine();
                switch (menu)
                {
                    case "1":
                        Console.Clear();
                        Console.WriteLine("Введите имя питомца");
                        cat.Name = Console.ReadLine();
                        //Console.WriteLine("Вы дали имя "+ cat.Name);


                        Console.ReadKey();
                        continue; 

                    case "2":
                        Console.Clear();
                        Console.WriteLine("Сейчас животное имеет "+ cat.CatColor);
                        cat.CatColor = Console.ReadLine();
                        Console.Clear();
                        Console.WriteLine("Вы изменили цвет на "+ cat.CatColor);
                        Console.ReadKey();
                        continue;
                    case "3":
                        Console.Clear();
                        Console.WriteLine("Вы пнули питомца");
                        cat.Punish();
                        Console.ReadKey();
                        continue;
                    case "4":
                        Console.Clear();
                        Console.WriteLine("Вы покормили питомца");
                        cat.Feed();
                        Console.ReadKey();
                        continue;
                    case "5":
                        Console.WriteLine("Возращатесь скорее");
                        Console.ReadKey();
                        break;

                    default:
                        Console.WriteLine("Вы ввели не верные данные.");
                        continue;





                } 
                break;
            }
            
        }
Пример #16
0
        static void Main(string[] args)
        {
            Console.WriteLine("Введите возраст кошки: ");
                var _age = Console.ReadLine();
                int age = int.Parse(_age);
                Cat cat = new Cat(age);

            int key;
            do
            {

                Console.WriteLine("Информация: ");
                Console.WriteLine(" ");
                Console.WriteLine("     Возраст: " + cat._age);
                Console.WriteLine(" ");
                Console.WriteLine("     Имя: " + cat.Name);
                Console.WriteLine(" ");
                Console.WriteLine("     Текущий цвет: " + cat.CurrentColor);

                Console.WriteLine(" ");
                Console.WriteLine(" ");

                Console.WriteLine("Меню");
                Console.WriteLine(" ");
                Console.WriteLine("1 - Задать имя кошки");
                Console.WriteLine(" ");
                Console.WriteLine("2 - Задать здоровый цвет кошки");
                Console.WriteLine(" ");
                Console.WriteLine("3 - Задать больной цвет кошки");
                Console.WriteLine(" ");
                Console.WriteLine("4 - Покормить");
                Console.WriteLine(" ");
                Console.WriteLine("5 - Наказать");
                Console.WriteLine(" ");
                Console.WriteLine("0 - Выйти из программы");

                key =Int32.Parse(Console.ReadLine());

                switch (key)
                {
                    case 1:
                        Console.WriteLine("Задайте имя кошке: ");
                        cat.Name = Console.ReadLine();
                        Console.Clear();
                        break;

                    case 2:
                        Console.WriteLine("Задайте здоровый цвет кошки: ");
                        cat.Color.HealthyColor = Console.ReadLine();
                        Console.Clear();
                        break;

                    case 3:
                        Console.WriteLine("Задайте больной цвет кошки: ");
                        cat.Color.HealthyColor = Console.ReadLine();
                        break;

                    case 4:
                        cat.Feed();
                        Console.Clear();
                        break;

                    case 5:
                        cat.Poonish();
                        Console.Clear();
                        break;
                }

            } while (key!=0);
        }
Пример #17
0
        static void Main(string[] args)
        {
            Console.WriteLine("\t\tРобот - кот\n");
            Console.WriteLine("Введите возраст кота");
            var    cat  = new Model.Cat(Console.ReadLine(), new CatColor());
            var    exit = false;
            String point;

            while (exit == false)
            {
                Console.WriteLine("Текущее состояние кошки:");
                Console.WriteLine("Имя: ");
                Console.WriteLine(cat.Name);
                Console.WriteLine("Возраст: ");
                Console.WriteLine(cat.Age);
                Console.WriteLine("Цвет: ");
                Console.WriteLine(cat.CurrentColor);

                Console.WriteLine(
                    "\tВыберите пункт меню:\na. Задать имя\nb. Покормить кошку\nc. Наказать кошку\nd. Изменить окрас кошки\n");

                point = Console.ReadLine();
                switch (point)
                {
                case "a":
                {
                    Console.Clear();
                    Console.WriteLine("\nВведите имя кошки\n");
                    cat.Name = Console.ReadLine();
                    break;
                }

                case "b":
                {
                    Console.Clear();
                    cat.Feed();
                    Console.WriteLine("\nКошка покормлена\n");
                    break;
                }

                case "c":
                {
                    Console.Clear();
                    cat.Punish();

                    Console.WriteLine("\nКошка наказана\n");
                    break;
                }

                case "d":
                {
                    Console.Clear();
                    Console.WriteLine("\na. Установить цвет здоровой кошки\nb. Установить цвет больной кошки\n");
                    switch (Console.ReadLine())
                    {
                    case "a":
                    {
                        Console.WriteLine("Введите цвет здоровой кошки: ");
                        cat.Color.HealthyColor = Console.ReadLine();
                        break;
                    }

                    case "b":
                    {
                        Console.WriteLine("Введите цвет больной кошки: ");
                        cat.Color.SickColor = Console.ReadLine();
                        break;
                    }
                    }
                    Console.Clear();
                    //cat.Color = Console.ReadLine();
                    break;
                }

                default:
                {
                    Console.Clear();
                    Console.WriteLine("\nВведены некоректные данные!\n");
                    break;
                }
                }
            }
        }
Пример #18
0
        static void Main(string[] args)
        {
            Console.Write("Здравствуйте, вас приветствует программа \"Электронная кошка!\" \n\n" +
                              "Введите желаемый возвраст кошки: ");

            var age = int.Parse(Console.ReadLine());
            var catColor = new CatColor
            {
                HeathyColor = "Белый",
                SickColor = "Зелёный"
            };
            var cat = new Cat(age, catColor);

            var flag1 = 0;
            while (true)
            {
                Console.Clear();
                Console.WriteLine("Состояние кошки:\n Имя кошки: {0}\n Возраст кошки: {1}\n Текущий цвет кошки: {2}\n",
                        cat.Name, cat.Age, cat.CurrentColor);

                Console.WriteLine("Вводите команды для перемещения по меню программы:");
                Console.WriteLine("1) Задать имя \n" + "2) Задать цвет \n" + "3) Ударить \n" + "4) Покормить \n" +
                                  "5) Выйти из программы \n");

                var switch1 = 0;
                try
                {
                    switch1 = int.Parse(Console.ReadLine());
                }
                catch (Exception){/* ignored*/}

                switch (switch1)
                {
                    case 1:
                    {
                        if (flag1 == 0)
                        {
                            Console.Write("Введите имя кошки: ");
                            cat.Name = Console.ReadLine();
                            flag1 = 1;
                        }
                        else
                        {
                            Console.WriteLine("Изивините, у вашей кошки уже есть имя, она должна привыкнуть к нему!");
                            Console.WriteLine("Нажмите любую клавишу для продолжения");
                            Console.ReadKey();
                        }
                        break;
                    }
                    case 2:
                    {
                        Console.Write("Введите цвет здоровой кошки: ");
                        cat.Color.HeathyColor = Console.ReadLine();
                        Console.Write("Введите цвет больной кошки: ");
                        cat.Color.SickColor = Console.ReadLine();
                        break;
                    }
                    case 3:
                    {
                        Console.WriteLine("Вы наказали свою кошку, её здоровье уменшилось на 1");
                        cat.Punish();
                        Console.ReadKey();
                        break;
                    }
                    case 4:
                    {
                        Console.WriteLine("Вы покормили свою кошку, её здоровье увеличилось на 1");
                        cat.Feed();
                        Console.ReadKey();
                        break;
                    }
                    case 5:
                    {
                        return;
                    }
                }
            }
        }
Пример #19
0
        // Транслит
        static void Translit()
        {
            Console.WriteLine("Koshka priobretena");

            // UI001: Запросить возраст кошки у пользователя
            string theAge;
            while (true)
            {
                Console.WriteLine("Vvedite vozrast koshki:");
                theAge = Console.ReadLine();

                // проверка того, что возраст введён верно.
                // (0 - допустимое значение, это значит что кошке меньше года)
                int check;
                bool b = int.TryParse(theAge, out check);
                if (b && (check >= 0))
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Vvedeno nedopustimoe znachenie.");
                    Console.WriteLine("Poprobujte escho raz, pozhalujsta.");
                    Console.WriteLine();
                }
            } // ..while (true)

            // создание экземпляра кошки
            Cat theCat = new Cat(theAge);

            // вывод меню
            while (true)
            {
                // UI004: Перед меню выводить информацию о кошке:
                // имя, возраст, текущий цвет
                Console.WriteLine("Imya:    {0}", theCat.Name);
                Console.WriteLine("Vozrast: {0}", theCat.Age);
                Console.WriteLine("Tekuschij tsvet: {0}", theCat.CurrentColor);
                Console.WriteLine();

                // UI002: Вывести меню со списком действий:
                // Задать имя
                // Задать цвет
                // Ударить
                // Покормить
                // UI003: После выполения выбранного действия не завершать работу
                // приложения, а снова выводить меню
                Console.WriteLine("Spisok dejstvij:");
                Console.WriteLine("1 - vyjti iz programmy");
                Console.WriteLine("2 - zadat' imya");
                Console.WriteLine("3 - zadat' tsvet");
                Console.WriteLine("4 - udarit'");
                Console.WriteLine("5 - pokormit'");

                // проверка того, что код операции введён верно.
                int op;
                string t = Console.ReadLine();
                int.TryParse(t, out op);
                if ((op < 1) || (op > 5))
                {
                    Console.WriteLine("Vvedeno nedopustimoe znachenie.");
                    Console.WriteLine("Poprobujte escho raz, pozhalujsta.");
                    Console.WriteLine();
                }

                switch (op)
                {
                    // некорректное значение
                    default:
                        Console.WriteLine("Oshybka. Programma ne dolzhna dostich etoj tochki.");
                        break;

                    // выход из программы
                    case 1:
                        Console.WriteLine("Vyhod.");
                        Console.ReadKey();
                        return;

                    // ввод имени кошки
                    case 2:
                        Console.WriteLine("Vvedite imya koshki:");
                        var theName = Console.ReadLine();
                        theCat.Name = theName;
                        break;

                    // задать цвет
                    case 3:
                        Console.WriteLine("Vvedite tsvet zdorovoj koshki:");
                        var theHealthyColor = Console.ReadLine();

                        Console.WriteLine("Vvedite tsvet bol'noj koshki:");
                        var theSickColor = Console.ReadLine();

                        theCat.Color.HealthyColor = theHealthyColor;
                        theCat.Color.SickColor = theSickColor;
                        break;

                    // ударить
                    case 4:
                        theCat.Punish();
                        Console.WriteLine("Vy udarili koshku.");
                        break;

                    // покормить
                    case 5:
                        theCat.Feed();
                        Console.WriteLine("Vy pokormili koshku.");
                        break;

                } // ..switch(op)
                Console.WriteLine();
            }
        }
Пример #20
0
        static void Main(string[] args)
        {
            Console.WriteLine("\t\tРобот - кот\n");
            Console.WriteLine("Введите возраст кота");
            var cat = new Model.Cat(Console.ReadLine(), new CatColor());
            var exit = false;
            String point;
            while (exit == false)
            {
                Console.WriteLine("Текущее состояние кошки:");
                Console.WriteLine("Имя: ");
                Console.WriteLine(cat.Name);
                Console.WriteLine("Возраст: ");
                Console.WriteLine(cat.Age);
                Console.WriteLine("Цвет: ");
                Console.WriteLine(cat.CurrentColor);

                Console.WriteLine(
                    "\tВыберите пункт меню:\na. Задать имя\nb. Покормить кошку\nc. Наказать кошку\nd. Изменить окрас кошки\n");

                point = Console.ReadLine();
                switch (point)
                {
                    case "a":
                        {
                            Console.Clear();
                            Console.WriteLine("\nВведите имя кошки\n");
                            cat.Name = Console.ReadLine();
                            break;
                        }
                    case "b":
                        {
                            Console.Clear();
                            cat.Feed();
                            Console.WriteLine("\nКошка покормлена\n");
                            break;
                        }
                    case "c":
                        {
                            Console.Clear();
                            cat.Punish();

                            Console.WriteLine("\nКошка наказана\n");
                            break;
                        }
                    case "d":
                        {
                            Console.Clear();
                            Console.WriteLine("\na. Установить цвет здоровой кошки\nb. Установить цвет больной кошки\n");
                            switch (Console.ReadLine())
                            {
                                case "a":
                                    {
                                        Console.WriteLine("Введите цвет здоровой кошки: ");
                                        cat.Color.HealthyColor = Console.ReadLine();
                                        break;
                                    }
                                case "b":
                                    {
                                        Console.WriteLine("Введите цвет больной кошки: ");
                                        cat.Color.SickColor = Console.ReadLine();
                                        break;
                                    }

                            }
                            Console.Clear();
                            //cat.Color = Console.ReadLine();
                            break;
                        }
                    default:
                        {
                            Console.Clear();
                            Console.WriteLine("\nВведены некоректные данные!\n");
                            break;
                        }
                }
            }
        }
Пример #21
0
        private static void Simulation(Cat cat)
        {
            while (true)
            {
                char key;
                string name;
                if (!string.IsNullOrEmpty(cat.Name))
                {
                    name = cat.Name;
                }
                else
                {
                    name = "Без имени";
                }
                Console.WriteLine("\n\nКошка " + name);
                Console.WriteLine("Возраст - " + cat.Age);
                Console.WriteLine("Текущий цвет - "+cat.CurrentColor+"\n");

                if (!string.IsNullOrEmpty(cat.Name))
                {
                    Console.WriteLine("1 - Изменить окрас\n2 - Покормить\n3 - Наказать\n0 - Выход\n");
                    key = Console.ReadKey().KeyChar;
                    int keyInt;
                    if (int.TryParse(key.ToString(),out keyInt)&&keyInt>0&&keyInt<4)
                    {
                        key = (keyInt + 1).ToString()[0];
                    }
                }
                else
                {
                    Console.WriteLine("1 - Задать имя\n2 - Изменить окрас\n3 - Покормить\n4 - Наказать\n0 - Выход\n");
                    key = Console.ReadKey().KeyChar;
                }

                switch (key)
                {
                    case '0':
                    {
                        Console.WriteLine();
                        return;
                    }
                    case '1':
                    {
                        Console.Write("\nВведите имя: ");
                        cat.Name = Console.ReadLine();
                        break;
                    }
                    case '2':
                    {
                        Console.Write("\nВведите цвет кошки в здоровом состоянии: ");
                        cat.Color.HealthyColor = Console.ReadLine();
                        Console.Write("Введите цвет кошки в болезненном состоянии: ");
                        cat.Color.SickColor = Console.ReadLine();
                        break;
                    }
                    case '3':
                    {
                        Console.WriteLine("\nВы покормили " + cat.Name);
                        cat.Feed();
                        break;
                    }
                    case '4':
                    {
                        Console.WriteLine("\nВы ударили " + cat.Name);
                        cat.Punish();
                        break;
                    }
                    default:
                    {
                        Console.WriteLine("\nНеизвестная команда!");
                        break;
                    }
                }
            }
        }
Пример #22
0
        // Кириллица
        static void Cyrillic()
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine("Кошка приобретена");

            // UI001: Запросить возраст кошки у пользователя
            string theAge;
            while (true)
            {
                Console.WriteLine("Введите возраст кошки:");
                theAge = Console.ReadLine();

                // проверка того, что возраст введён верно.
                // (0 - допустимое значение, это значит что кошке меньше года)
                int check;
                bool b = int.TryParse(theAge, out check);
                if (b && (check >= 0))
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Введено недопустимое значение.");
                    Console.WriteLine("Попробуйте ещё раз, пожалуйста.");
                }
            } // ..while (true)

            // создание экземпляра кошки
            Cat theCat = new Cat(theAge);

            // вывод меню
            while (true)
            {
                // UI004: Перед меню выводить информацию о кошке:
                // имя, возраст, текущий цвет
                Console.WriteLine("Имя: {0}", theCat.Name);
                Console.WriteLine("Возраст: {0}", theCat.Age);
                Console.WriteLine("Текущий цвет: {0}", theCat.CurrentColor);
                Console.WriteLine();

                // UI002: Вывести меню со списком действий:
                // Задать имя
                // Задать цвет
                // Ударить
                // Покормить
                // UI003: После выполения выбранного действия не завершать работу
                // приложения, а снова выводить меню
                Console.WriteLine("Список действий:");
                Console.WriteLine("1 - выйти из программы");
                Console.WriteLine("2 - задать имя");
                Console.WriteLine("3 - задать цвет");
                Console.WriteLine("4 - ударить");
                Console.WriteLine("5 - покормить");

                // проверка того, что код операции введён верно.
                int op;
                string t = Console.ReadLine();
                int.TryParse(t, out op);
                if ((op < 1) || (op > 5))
                {
                    Console.WriteLine("Введено недопустимое значение.");
                    Console.WriteLine("Попробуйте ещё раз, пожалуйста.");
                    continue;
                }

                switch (op)
                {
                    // некорректное значение
                    default:
                        Console.WriteLine("Ошибка. Програма не должна достигунть этой точки");
                        break;

                    // выход из программы
                    case 1:
                        Console.WriteLine("Выход.");
                        Console.ReadKey();
                        return;

                    // ввод имени кошки
                    case 2:
                        Console.WriteLine("Введите имя кошки:");
                        var theName = Console.ReadLine();
                        theCat.Name = theName;
                        break;

                    // задать цвет
                    case 3:
                        Console.WriteLine("Введите цвет здоровой кошки:");
                        var theHealthyColor = Console.ReadLine();

                        Console.WriteLine("Введите цвет больной кошки:");
                        var theSickColor = Console.ReadLine();

                        theCat.Color.HealthyColor = theHealthyColor;
                        theCat.Color.SickColor = theSickColor;
                        break;

                    // ударить
                    case 4:
                        theCat.Punish();
                        Console.WriteLine("Вы ударили кошку.");
                        break;

                    // покормить
                    case 5:
                        theCat.Feed();
                        Console.WriteLine("Вы покормили кошку.");
                        break;

                } // ..switch(op)
                Console.WriteLine();
            }
        }
Пример #23
0
        static void Main()
        {
            var color = new CatColor();

            string age;

            Console.Write("Покупка питомца. \nВведите возраст: ");
            age = Console.ReadLine();

            var cat = new Cat(color, age);

            Console.Write("Задайте цвет для здоровой кошки: ");
            color.HealthyColor = Console.ReadLine();

            Console.Write("Задайте цвет для больной кошки: ");
            color.SickColor = Console.ReadLine();

            int i;
            do
            {
                Console.Write("Имя: " + cat.Name);
                Console.Write("\nВозраст: " + cat.Age);
                Console.Write("\nЦвет: " + cat.CurrentColor);

                Console.Write("\nМеню:\n1) Задать имя \n2) Ударить! \n3) Покормить \n4) Выйти \n\nВаше решение: ");
                i = int.Parse(Console.ReadLine());
                switch (i)
                {
                    case 1:
                        Console.Write("Задать имя: ");
                        cat.Name = Console.ReadLine();
                        Console.WriteLine("Имя: " + cat.Name);
                        break;
                    case 2:
                        if (cat.Age == null)
                        {
                            Console.WriteLine("Сначала введите возраст!");
                            break;
                        }
                        cat.Punish();
                        Console.WriteLine("Вы ударили ее и теперь здоровье кошки равно " + cat.Health);
                        Console.WriteLine("Цвет изменился на " + (cat.CurrentColor));
                        break;
                    case 3:
                        if (cat.Age == null)
                        {
                            Console.WriteLine("Сначала введите возраст!");
                            break;
                        }
                        cat.Feed();
                        Console.WriteLine("Вы покормили ее и теперь здоровье кошки равно " + cat.Health);
                        Console.WriteLine("Цвет изменился на " + (cat.CurrentColor));
                        break;
                    case 4:
                        Console.WriteLine("Вы решили выйти");
                        break;
                    default:
                        Console.WriteLine("Вы что-то другое нажали...");
                        break;
                }
                Console.Write("\n\n");

            }
            while (i != 4);
        }
Пример #24
0
        private static void Main(string[] args)
        {
            List<Cat> cats = new List<Cat>();

            Console.WriteLine("Кошка для программиста");
            while (true)
            {
                Console.WriteLine("\n1 - Новая\n2 - Открыть\n0 - Выход\n");
                var key = Console.ReadKey().KeyChar;
                switch (key)
                {
                    case '1':

                        Console.Write("\n\nВведите возраст кошки: ");
                        int age;
                        while (!int.TryParse(Console.ReadLine(), out age))
                        {
                            Console.WriteLine("\nВозраст введен не корректно! Попробуйте еще раз.");
                        }
                        Cat c = new Cat(age);
                        cats.Add(c);
                        Simulation(c);
                        cats[cats.Count - 1] = c;
                        break;

                    case '2':

                        Console.WriteLine();
                        Console.WriteLine();
                        for (int i = 0; i < cats.Count; i++)
                        {
                            Console.WriteLine((i + 1).ToString() + "- " + cats[i].Name);
                        }
                        Console.WriteLine("0-Назад");

                        int catNum;
                        while (true)
                        {
                            var keyString = Console.ReadLine();
                            int num;
                            if (int.TryParse(keyString, out num) && num >= 0 && num <= cats.Count)
                            {
                                catNum = num;
                                break;
                            }
                        }

                        if (catNum == 0)
                        {
                            break;
                        }
                        for (int i = 0; i < cats.Count; i++)
                        {

                            if (catNum == i + 1)
                            {
                                Cat cat = cats[i];
                                Simulation(cat);
                                break;
                            }
                        }

                        break;

                    case '0':
                        return;
                    default:
                        Console.WriteLine("\nНеизвестная команда!");
                        break;

                }
            }
        }