static void Main(string[] args) { Carrots carrots = new Carrots(0.82); carrots.Attach(new Restaurant("Mackay's", 0.77)); carrots.Attach(new Restaurant("Johnny's Sports Bar", 0.74)); carrots.Attach(new Restaurant("Salad Kingdom", 0.75)); carrots.PricePerPound = 0.79; carrots.PricePerPound = 0.86; carrots.PricePerPound = 0.74; carrots.PricePerPound = 0.81; }
static void Main(string[] args) { // Create price watch for Carrots and attach restaurants that buy carrots from suppliers. Carrots carrots = new Carrots(0.82); carrots.Attach(new Restaurant("Mackay's", 0.77)); carrots.Attach(new Restaurant("Johnny's Sports Bar", 0.74)); carrots.Attach(new Restaurant("Salad Kingdom", 0.75)); // Fluctuating carrot prices will notify subscribing restaurants. carrots.PricePerPound = 0.79; carrots.PricePerPound = 0.76; carrots.PricePerPound = 0.74; carrots.PricePerPound = 0.81; Console.ReadKey(); }