Пример #1
0
 public void Update(Veggies veggie)
 {
     Console.WriteLine("Notified {0} of {1}'s " + " price change to {2:C} per pound.", _name, veggie.GetType().Name, veggie.PricePerPound);
     if (veggie.PricePerPound < _purchaseThreshold)
     {
         Console.WriteLine(_name + " wants to buy some " + veggie.GetType().Name + "!");
     }
 }
Пример #2
0
        /// <summary>
        /// Implement feom IObserver.
        /// </summary>
        /// <param name="veggies"> Concrete subject. </param>
        public void Update(Veggies veggies)
        {
            Console.WriteLine($"Notified {_name} of {veggies.GetType().Name}'s  price change to {veggies.GetPricePerPound()} per pound.");

            if (veggies.GetPricePerPound() < _purchaseThreshold)
            {
                Console.WriteLine($"{_name} wants to buy some {veggies.GetType().Name}!");
            }
        }
Пример #3
0
 public Restaurant(string name, double purchaseThreshold, Veggies veggie)
 {
     this.name = name;
     this.purchaseThreshold = purchaseThreshold;
     this.veggie            = veggie;
 }