Пример #1
0
        public void Feeding()
        {
            string        drink;
            int           foodAmount;
            FoodEventArgs fargs;

            try
            {
                Console.WriteLine("Enter the drink of animal: (For successful feeding, you should type 'Water')");
                drink = Console.ReadLine();

                Console.WriteLine("Enter the amount of food: ");
                foodAmount = Int32.Parse(Console.ReadLine());

                fargs = new FoodEventArgs(drink, foodAmount);
            }

            catch
            {
                fargs = new FoodEventArgs();
            }

            Console.WriteLine("Feeder {0} is feeding animals...\n", name);

            if (FeedingEvent != null)
            {
                FeedingEvent((Feeder)this, fargs);
            }
        }
Пример #2
0
 public override void Feed(Feeder f, FoodEventArgs fargs)
 {
     if (isHungry)
     {
         makeSound();
         Console.WriteLine("Cat is feeding by " + f.name);
         try
         {
             Exceptions.ProcessFood(fargs.drink, fargs.foodAmount);
             Exceptions.ProcessCatFood(fargs.foodAmount);
         }
         catch (Exceptions ex)
         {
             Console.WriteLine("It is incorrect amount of food for Cat or incorrect drink" + ex.Message);
         }
     }
     else
     {
         Console.WriteLine("Meow, I am not hungry");
     }
 }
Пример #3
0
 public override void Feed(Feeder f, FoodEventArgs fargs)
 {
     if (isHungry)
     {
         makeSound();
         Console.WriteLine("Hamster is feeding by " + f.name);
         try
         {
             Exceptions.ProcessFood(fargs.drink, fargs.foodAmount);
             Exceptions.ProcessHamsterFood(fargs.foodAmount);
         }
         catch
         {
             Console.WriteLine("It is incorrect amount of food for Hamster or incorrect drink");
         }
     }
     else
     {
         Console.WriteLine("I am not hungry");
     }
 }
Пример #4
0
 abstract public void Feed(Feeder f, FoodEventArgs fargs);