Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // Create timer, and set the time for five seconds through the constructor
            CustomerTimer timer = new CustomerTimer(5);

            // Creating a object OVEN without signing up for an event from the constructor
            Oven oven = new Oven();

            // Creating a object WASHING MACHINE with signing up for an event from the constructor
            WashingMachine wm = new WashingMachine(timer);

            // Creating a object ALARM CLOCK with signing up for an event from the constructor
            AlarmClock ac = new AlarmClock(timer);

            //Signing of the object OVEN to the event using interface method
            oven.SubscribeToEventTimerAlarm(timer);

            // Timer start
            timer.StartTimer();

            Console.ReadKey();
        }
Ejemplo n.º 2
0
 public void UnsubscribeToEventTimerAlarm(CustomerTimer timer)
 {
     if (timer == null)
         throw new ArgumentNullException("CustomerTimer is null");
     timer.Alarm -= ProcessingEventAlarmClassOven;
 }
Ejemplo n.º 3
0
 public Oven(CustomerTimer timer)
 {
     if (timer != null)
         SubscribeToEventTimerAlarm(timer);
 }
 public void SubscribeToEventTimerAlarm(CustomerTimer timer)
 {
     if (timer == null)
         throw new ArgumentNullException("Timer is null");
     timer.Alarm += ProcessingEventAlarmClassWashingMachine;
 }
 public WashingMachine(CustomerTimer timer)
 {
     if (timer != null)
         SubscribeToEventTimerAlarm(timer);
 }