static void Main(string[] args) { Cat cat = new Cat("Пейн", new DateTime(2014, 03, 31)); Console.WriteLine($"Коту по имени {cat.Name} уже {cat.GetAge()} лет"); Cat cat2 = new Cat("Джуга", new DateTime(2018, 10, 14)); Console.WriteLine($"Коту по имени {cat2.Name} уже {cat2.GetAge()} лет"); CatSmartHouse catHouse = new CatSmartHouse(900); catHouse.AddCat(cat); catHouse.AddCat(cat2); Console.SetCursorPosition(0, catHouse.CatsCount + 1); CommandCenter CC = new CommandCenter(catHouse); }
public void WaitCommand(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] == "+") { CatHouse.hangryLimit -= Convert.ToInt32(array[2]); } else if (array[1] == "-") { CatHouse.hangryLimit += Convert.ToInt32(array[2]); } } } }
public CommandCenter(CatSmartHouse catHouse) { CatSmartHouse = catHouse; WaitCommand(CatSmartHouse); }