예제 #1
0
파일: CommandCenter.cs 프로젝트: Limakon/DZ
        public void WaitCommand(Cat cat, CatSmartHouse CatHouse)
        {

            string command = "";
            while (command != "exit")
            {
                Console.SetCursorPosition(0, CatHouse.CatsCount + 1);
                command = Console.ReadLine();
                string[] array = command.Split();
                if (array[0] == "store")
                {
                    int smth = Convert.ToInt32(array[2]);
                    CatHouse.FoodResourse += smth;

                }

                if (command == "cls")
                {
                    for (int i = 0; i < 1000; i++)
                    {
                        Console.Clear();
                        Console.Write(i);
                    }
                }
                else if (command == "help")
                {
                    Console.WriteLine("Списки доступных вам команд: \n");
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("Добавить корма в вольер:      store *название корма* *количество корма*");
                    Console.WriteLine("Очистить консоль:             cls");
                    Console.WriteLine("Изменить границу голода:      ChangeHungryLimit *на сколько*");
                    Console.ResetColor();
                }
                if (command == "ChangeHungryLimit")
                {
                    if (array[1] == "+")
                    {
                        int.TryParse(Console.ReadLine(), out eat);
                        eat -= Convert.ToInt32(array[2]);
                    }
                    else if (array[1] == "-")
                    {
                        int.TryParse(Console.ReadLine(), out eat);
                        eat += Convert.ToInt32(array[2]);    
                    }
                }
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: Limakon/DZ
        static void Main(string[] args)
        {
            Cat c = new Cat("Kit", new DateTime(2005, 8, 7));

            c.MakeNoise();
            Console.WriteLine($"Кошке по имени {c.Name} уже {c.GetAge()} лет");
            //c.HungryStatus = 150;

            Cat ct = new Cat($"Top", new DateTime(2006, 9, 8));

            ct.MakeNoise();
            Console.WriteLine($"Кошке по имени {ct.Name} уже {ct.GetAge()} лет");


            CatSmartHouse catSmartH = new CatSmartHouse(900);

            catSmartH.AddCat(c);
            catSmartH.AddCat(ct);
            Console.ReadLine();
        }
예제 #3
0
파일: CommandCenter.cs 프로젝트: Limakon/DZ
 public CommandCenter(CatSmartHouse CatHouse)   
 {
     CatSmartHouse = CatHouse;
     WaitCommand();
 }