Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. using System;
  2.  
  3. public class Consumer
  4. {
  5. private string name, interestedIn;
  6.  
  7. public Consumer(string name, string interestedIn)
  8. {
  9. this.name = name;
  10. this.interestedIn = interestedIn;
  11. }
  12.  
  13. public void NewCarIsHere(object sender, CarInfoEventArgs e)
  14. {
  15. if (e.Car.Contains(interestedIn))
  16. Console.WriteLine("info dla {0}; jest nowe auto: {1} dostępne od {2} do {3}",
  17. name, e.Car, e.BeginTime.ToShortDateString(), e.EndTime.ToShortDateString());
  18. }
  19. }
  20.  
  21.  
  22.  
  23.  
  24. using System;
  25.  
  26. public class CarInfoEventArgs : EventArgs
  27. {
  28. public CarInfoEventArgs(string car, DateTime beginTime, DateTime endTime)
  29. {
  30. this.Car = car;
  31. BeginTime = beginTime;
  32. EndTime = endTime;
  33. }
  34.  
  35. public string Car { get; private set; }
  36.  
  37. public DateTime BeginTime { get; private set; }
  38.  
  39. public DateTime EndTime { get; private set; }
  40. }
  41.  
  42. public class CarDealer
  43. {
  44. public event EventHandler<CarInfoEventArgs> NewCarInfo;
  45.  
  46. public void NewCar(string car, DateTime beginTime, DateTime endTime)
  47. {
  48. Console.WriteLine("Dealer, nowe auto: {0}, dostępne od {1} do {2}",
  49. car, beginTime.ToShortDateString(), endTime.ToShortDateString());
  50. NewCarInfo?.Invoke(this, new CarInfoEventArgs(car, beginTime, endTime));
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement