Пример #1
0
        public override IAnimal Create()
        {
            var   tuple = AnimalParams();
            float height = tuple.Item1; float weight = tuple.Item2; string eyeColor = tuple.Item3;


            NotificationService.Write("Введите имя: ");
            string name = ReaderService.ReadLine();

            NotificationService.Write("Введите породу: ");
            string breed = ReaderService.ReadLine();

            bool isItWooled = BoolEnter("У нее есть шерсть?");

            string coatColor;

            if (isItWooled)
            {
                NotificationService.Write("Введите цвет шерсти: ");
                coatColor = ReaderService.ReadLine();
            }
            else
            {
                coatColor = "Шерсти нет";
            }

            bool     isItVaccinated = BoolEnter("У нее есть прививки?");
            DateTime birthDate      = (DateTime)DateEnter("Введите дату рождения");

            return(new Cat(height, weight, eyeColor, name, breed, isItVaccinated, coatColor, birthDate, isItWooled, SoundService));
        }
Пример #2
0
        public override IAnimal Create()
        {
            var    tuple    = AnimalParams();
            float  height   = tuple.Item1;
            float  weight   = tuple.Item2;
            string eyeColor = tuple.Item3;

            NotificationService.Write("Введите среду обитания: ");
            string habitat = ReaderService.ReadLine();

            DateTime dateOfFind = (DateTime)DateEnter("Введите дату нахождения");

            return(new Tiger(height, weight, eyeColor, habitat, dateOfFind, SoundService));
        }
Пример #3
0
        public override void Execute()
        {
            NotificationService.Write("Выберете животное, которое хотите добавить:\n1 - Кошка\n2 - Собака\n3 - Курица\n4 - Аист\n5 - Тигр\n6 - Волк\n");
            string choose = ReaderService.ReadLine();

            //Необходима проверка на наличие команды в выборе
            if (_dict.ContainsKey(choose))
            {
                Zoo.Add(_factory.GetAnimal(_dict[choose]));
            }
            else
            {
                throw new IncorrectActionException("Неверный ввод.");
            }
        }
Пример #4
0
        public override void Execute()
        {
            NotificationService.Write("Введите путь к файлу (пустая строка означает путь по умолчанию): \n");
            string text = ReaderService.ReadLine();

            if (string.IsNullOrEmpty(text))
            {
                text = "Input.txt";
            }
            try
            {
                //Лучше использовать ?.
                Zoo.Add(_fileReader.Read(text));
            }
            //Не все виды ошибок перехвачены, возможны падения программы
            catch (IOException)
            {
                NotificationService.Write("File or directory does not exist.");
            }
        }
Пример #5
0
        public override IAnimal Create()
        {
            var    tuple    = AnimalParams();
            float  height   = tuple.Item1;
            float  weight   = tuple.Item2;
            string eyeColor = tuple.Item3;

            //Избавиться от дублирования кода
            NotificationService.Write("Введите имя: ");
            string name = ReaderService.ReadLine();

            NotificationService.Write("Введите породу:");
            string breed = ReaderService.ReadLine();

            NotificationService.Write("Введите цвет шерсти: ");
            string coatColor = ReaderService.ReadLine();

            bool     isItVaccinated = BoolEnter("У нее есть прививки?");
            DateTime birthDate      = (DateTime)DateEnter("Введите дату рождения");

            bool isItTrained = BoolEnter("Собака тренированная?");

            return(new Dog(height, weight, eyeColor, name, breed, isItVaccinated, coatColor, birthDate, isItTrained, SoundService));
        }