Beispiel #1
0
        public string Vaccinate(string name, int procedureTime)
        {
            this.DoesExist(name);

            var animal = hotel.GetAnimal(name);

            if (this.procedures.Any(p => p.GetType().Name == "Vaccinate"))
            {
                this.procedures.First(p => p.GetType().Name == "Vaccinate")
                .DoService(animal, procedureTime);
            }
            else
            {
                Procedure procedure = new Vaccinate();
                procedure.DoService(animal, procedureTime);
                this.procedures.Add(procedure);
            }

            return($"{name} had vaccination procedure");
        }
Beispiel #2
0
        public string Vaccinate(string name, int procedureTime)
        {
            if (!this.hotel.Animals.ContainsKey(name))
            {
                throw new ArgumentException($"Animal {name} does not exist");
            }

            var animal = this.hotel.Animals.First(x => x.Value.Name == name).Value;

            if (this.procedures.Any(x => x.GetType() == typeof(Vaccinate)))
            {
                this.procedures.First(x => x.GetType() == typeof(Vaccinate)).DoService(animal, procedureTime);
            }

            else
            {
                var vaccine = new Vaccinate();
                vaccine.DoService(animal, procedureTime);
                this.procedures.Add(vaccine);
            }

            return($"{animal.Name} had vaccination procedure");
        }