示例#1
0
        public static void Main()
        {
            IKitchenMediator mediator = new KitchenMediator();

            Employee waiter = new Waiter(Constants.DisplayWaiter, mediator);
            Employee cook   = new Cook(Constants.DisplayCook, mediator);

            mediator.Register(waiter);
            mediator.Register(cook);

            waiter.Send(Constants.DisplayCook, PrintMessages.Ordered);
            cook.Send(Constants.DisplayWaiter, PrintMessages.Ready);
        }
示例#2
0
        public static void Main()
        {
            IKitchenMediator mediator = new KitchenMediator();

            string john  = Constants.DisplayJohn;
            string peter = Constants.DisplayPeter;

            Employee waiter = new Waiter(john, mediator);
            Employee cook   = new Cook(peter, mediator);

            mediator.Register(waiter);
            mediator.Register(cook);

            waiter.Send(john, PrintMessages.Ordered);
            cook.Send(peter, PrintMessages.Ready);
        }
示例#3
0
        static void Main(string[] args)
        {
            var orders = new List <Order>
            {
                new Order("Basic burger", Menu.BasicBurger, 2),
                new Order("Cheese burger", Menu.CheeseBurger, 2),
                new Order("Double Burger", Menu.DoubleBurger, 2),
                new Order("full burger", Menu.FullBurger, 2),
                new Order("french fries with ketchup", Menu.FriesWithKetchup, 4),
                new Order("fries", Menu.NormalFries, 3)
            };

            Timer timer = new Timer();

            timer.Start();
            var cook = new Cook(orders);

            cook.StartCooking();
            timer.Stop();
            Console.WriteLine($"The program ran at {timer.Interval} ms");
            timer.Dispose();
        }
        static void Main(string[] args)
        {
            Stopwatch watch   = new Stopwatch();
            Kitchen   kitchen = new Kitchen(watch);
            Cook      cook1   = new Cook(watch, kitchen, "Cook1");
            Cook      cook2   = new Cook(watch, kitchen, "Cook2");
            //Cook cook3 = new Cook(watch, kitchen, "Cook3");

            Order order1;

            order1 = new Order("Order1", watch);
            order1.SetOrderItems(new List <IFood>()
            {
                new BasicBurger(order1, watch),
                new BasicBurger(order1, watch),
                new CheeseBurger(order1, watch),
                new CheeseBurger(order1, watch),
                new DoubleBurger(order1, watch),
                new DoubleBurger(order1, watch),
                new FullBurger(order1, watch),
                new FullBurger(order1, watch),
                new FrenchFriesWithKetchup(order1, watch),
                new FrenchFriesWithKetchup(order1, watch),
                new FrenchFriesWithKetchup(order1, watch),
                new FrenchFriesWithKetchup(order1, watch),
                new FrenchFries(order1, watch),
                new FrenchFries(order1, watch),
                new FrenchFries(order1, watch),
            });
            Order order2;

            order2 = new Order("Order2", watch);
            order2.SetOrderItems(new List <IFood>()
            {
                new BasicBurger(order2, watch),
                new BasicBurger(order2, watch),
                new CheeseBurger(order2, watch),
                new CheeseBurger(order2, watch),
                new DoubleBurger(order2, watch),
                new DoubleBurger(order2, watch),
                new FullBurger(order2, watch),
                new FullBurger(order2, watch),
                new FrenchFriesWithKetchup(order2, watch),
                new FrenchFriesWithKetchup(order2, watch),
                new FrenchFriesWithKetchup(order2, watch),
                new FrenchFriesWithKetchup(order2, watch),
                new FrenchFries(order2, watch),
                new FrenchFries(order2, watch),
                new FrenchFries(order2, watch),
            });
            var orders = new List <Order>()
            {
                order1
            };

            watch.Start();
            kitchen.RecieveOrders(orders);
            var t  = cook1.StartWork();
            var t2 = cook2.StartWork();

            t.Wait();
            //t2.Wait();
        }