Beispiel #1
0
        public void Tickets_On_Sale(Int32 price) //Event Handler for Ticket Thread
        {
            Console.WriteLine(thread_name + " has tickets that are on sale");
            Console.WriteLine("The new price is: $" + price);

            Int32  unit_price  = price;
            Int32  need        = rand_num.Next(2, 10);
            Int32  card_num    = rand_num.Next(1000, 9999);
            string sender_ID   = thread_name;
            string receiver_ID = "Park Thread";

            Int32   standard_order = 400;
            Int32   current_order  = unit_price * need;
            Boolean place_order    = ((current_order > standard_order) || (need > 3));

            if (place_order) //Check if order can be placed
            {
                Order order = new Order();
                order.Set_Unit_Price(unit_price);
                order.Set_Num_Tickets(need);
                order.Set_Card_Number(card_num);
                order.Set_Sender_ID(sender_ID);
                order.Set_Receiver_ID(receiver_ID);
                buffer = new Multi_Cell_Buffer();
                buffer.Set_One_Cell(order);
            }
            else //Order did not meet demand
            {
                Console.WriteLine("\n" + thread_name + " did not place order");
                Console.WriteLine("Not enough demand (only " + need + " tickets needed)\n");
            }
        }
Beispiel #2
0
        Multi_Cell_Buffer buffer;                      //Create buffer to hold items

        public void Run_Park()                         //Runs the regular Park functionality
        {
            buffer = new Multi_Cell_Buffer();          //Create the Park order buffer

            while (counter < 20)                       //Run until 20 price cuts have occurred
            {
                Thread.Sleep(rand_num.Next(300, 500)); //Wait

                Int32 price = Pricing_Model();
                Park.Price_Updated(price);
                Order order = buffer.Get_One_Cell(); //Collects an order from the buffer

                if (order != null)                   //If an order exists
                {
                    Order_Processing order_process    = new Order_Processing(order);
                    Thread           order_processing = new Thread(new ThreadStart(order_process.Create_Order));
                    order_processing.Start();
                    order_processing.Join();
                }
            }
            //Shut down the Park functionality
            Console.WriteLine("PARK THREAD ENDING");
            Console.WriteLine(counter + " Price cuts have occurred");
        }