示例#1
0
        public void airlineFunc()
        {
            for (Int32 i = 0; i < 20; i++) //price cuts stops after 20
            {
                Thread.Sleep(500);
                // Take the order from the queue of the orders;
                // Decide the price based on the orders

                Int32 p = rng.Next(50, 200); // Generate a random price
                Airline.changePrice(p);

                if (multiCellBuffer.order != null)
                {
                    Console.WriteLine("--------------------------------------------------- Airline is Processing Order for Travel Agency {0}", multiCellBuffer.order.getSender());

                    Thread link = new Thread(() => Airline.orderProcessing(multiCellBuffer.order, multiCellBuffer.price)); //Generate new order processing thread
                    link.Start();
                    multiCellBuffer.getOneCell();
                }
            }
        }
示例#2
0
        public void travelAgencyFunc()
        {
            Order order = new Order();

            Airline airline = new Airline(multiCellBuffer);

            for (Int32 i = 0; i < 20; i++)
            {
                Thread.Sleep(500);

                Int32 p = airline.getPrice();
                Console.WriteLine("Travel Agency{0} has everyday low price: ${1} each", Thread.CurrentThread.Name, p);


                if (Program.onSaleFlag == 1)
                {
                    multiCellBuffer.price = p;
                    createOrder(order, multiCellBuffer.price, Thread.CurrentThread.Name);  //Generate order object if flash sale occurs
                }
            }
        }