Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Consumer
- {
- private string name, interestedIn;
- public Consumer(string name, string interestedIn)
- {
- this.name = name;
- this.interestedIn = interestedIn;
- }
- public void NewCarIsHere(object sender, CarInfoEventArgs e)
- {
- if (e.Car.Contains(interestedIn))
- Console.WriteLine("info dla {0}; jest nowe auto: {1} dostępne od {2} do {3}",
- name, e.Car, e.BeginTime.ToShortDateString(), e.EndTime.ToShortDateString());
- }
- }
- using System;
- public class CarInfoEventArgs : EventArgs
- {
- public CarInfoEventArgs(string car, DateTime beginTime, DateTime endTime)
- {
- this.Car = car;
- BeginTime = beginTime;
- EndTime = endTime;
- }
- public string Car { get; private set; }
- public DateTime BeginTime { get; private set; }
- public DateTime EndTime { get; private set; }
- }
- public class CarDealer
- {
- public event EventHandler<CarInfoEventArgs> NewCarInfo;
- public void NewCar(string car, DateTime beginTime, DateTime endTime)
- {
- Console.WriteLine("Dealer, nowe auto: {0}, dostępne od {1} do {2}",
- car, beginTime.ToShortDateString(), endTime.ToShortDateString());
- NewCarInfo?.Invoke(this, new CarInfoEventArgs(car, beginTime, endTime));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement