using System.Collections;
using System.Collections.Generic;
using assignment2014_09_22;
namespace assignment2014_09_22
public static void Main(string[] args)
Queue<Customer> myQueue = new Queue<Customer >();
myQueue.Enqueue(new Customer ("Vithu "," Raja"));
myQueue.Enqueue(new Customer ("Hasan "," Umbra"));
myQueue.Enqueue(new Customer( "Diana "," mohan"));
myQueue.Enqueue(new Customer( "Paul "," thakkar"));
myQueue.Enqueue(new Customer ("Bill "," Gates"));
while (myQueue.Count > 0)
Customer cus = myQueue.Dequeue();
cus.CustomerEvent += OnMealChange;
tb.TableEvent += cus.HandleOpenTable;
while (cus.meal != Customer.Meals.done)
tb.TableEvent -= cus.HandleOpenTable;
Console.WriteLine("Table is full");
public static void OnMealChange(object sender, CustomerEventArgs e)
Console.WriteLine ("{0}{1} is having {2}",e.cus.FirstName ,e.cus.LastName ,e.cus.meal);
public enum Meals { none, appetizer, main, desert, done }
public EventHandler<CustomerEventArgs>CustomerEvent;
public Customer (string firstName,string lastName)
this.FirstName = firstName;
this.LastName = lastName;
public void HandleOpenTable(object sender, TableInfoEventsArgs e)
Console.WriteLine("{0}{1} got a table ", this.FirstName, this.LastName);
public void MenuChange( )
EventHandler<CustomerEventArgs>CMealInfo= CustomerEvent;
this.meal=Meals.appetizer ;
this.meal =Meals.desert ;
CMealInfo(this,new CustomerEventArgs(this));
public class CustomerEventArgs:EventArgs
public Customer cus{get; private set;}
public CustomerEventArgs(Customer cus)
public EventHandler<TableInfoEventsArgs> TableEvent;
public void OnTableOpen()
Console.WriteLine("\nTable Open ");
Console.WriteLine("----------");
EventHandler<TableInfoEventsArgs> MyHandler = TableEvent;
MyHandler(this, new TableInfoEventsArgs(this));
public class TableInfoEventsArgs:EventArgs
public Table tb{get;set;}
public TableInfoEventsArgs (Table tb)