コード例 #1
0
        //this class is an event listener that creates a new order and
        //adds it to the list of queued orders to be added to the buffer in the agencyFunc
        //THIS CALLBACK EVENT HANDLER NEEDS TO CHANGE SO I RECEIVE PREVIOUS PRICE AND CURRENT
        // Joern on 1/15/13 - previous price added
        public void priceCutEvent(int newPrice, int prevPrice)
        {
            if (orderNumber < 10)
            {
                //generate random room demand
                roomDemand = randDemand.Next(50, 100);


                //generate scaled demand for first order without previous price
                //assuming its a price drop of 10%

                tempDemand = ((double)prevPrice / (double)newPrice) * roomDemand;
                roomDemand = (int)tempDemand;



                //create new order;
                currentOrder.setnoRooms(roomDemand);
                currentOrder.setID(senderId.ToString());
                currentOrder.setCardNo(senderId + 5000);
                currentOrder.setPrice((double)newPrice);
                currentOrder.setOrderID(senderId + "-" + orderNumber);
                orderNumber++;

                //add new order to pending list
                queuedOrders.Add(currentOrder);

                //reset current order
                currentOrder = new OrderClass();
                //Console.WriteLine("Received : {0}", newPrice);
                //Console.WriteLine("Sender id = {0}", senderId);
            }
        }
コード例 #2
0
ファイル: Decoder.cs プロジェクト: twynne20/CSE445_Project2
        public void setOrder(String str)
        {
            EncryptionService.ServiceClient serviceClient = new EncryptionService.ServiceClient();
            string temp = serviceClient.Decrypt(str); //Decrypts string

            /*
             * OrderClass.set() //All of OrderClass' attributes
             * OrderClass.set()....etc
             */
            char[]        chStr = temp.ToCharArray(); //Creates an array of char from string
            StringBuilder temp2 = new StringBuilder();
            StringBuilder temp3 = new StringBuilder();
            StringBuilder temp4 = new StringBuilder();
            StringBuilder temp5 = new StringBuilder();
            StringBuilder temp6 = new StringBuilder();
            StringBuilder temp7 = new StringBuilder();
            int           j     = 0;

            for (int i = 0; i < chStr.Length; ++i)
            {
                switch (j)
                {
                case 0:
                {
                    while (chStr[i] != ' ')
                    {
                        temp2.Append(chStr[i]);     //builds a string based on input up to first space
                        ++i;
                    }
                    break;
                }

                case 1:
                {
                    while (chStr[i] != ' ')
                    {
                        temp3.Append(chStr[i]);     //builds a string based on input up to second space
                        ++i;
                    }
                    break;
                }

                case 2:
                {
                    while (chStr[i] != ' ')
                    {
                        temp4.Append(chStr[i]);     //builds a string based on input up to third space
                        ++i;
                    }
                    break;
                }

                case 3:
                {
                    while (chStr[i] != ' ')
                    {
                        temp5.Append(chStr[i]);     //builds a string based on input up to third space
                        ++i;
                    }
                    break;
                }

                case 4:
                {
                    while (chStr[i] != ' ')
                    {
                        temp6.Append(chStr[i]);     //builds a string based on input up to third space
                        ++i;
                    }
                    break;
                }

                case 5:
                {
                    while (chStr[i] != ' ')
                    {
                        temp7.Append(chStr[i]);     //builds a string based on input up to third space
                        ++i;
                    }
                    break;
                }
                }
                ++j;
            }

            int amt    = Convert.ToInt32(temp2.ToString()); //Converts StringBuilder type to Int
            int cardNo = Convert.ToInt32(temp3.ToString());

            string senderID = temp4.ToString();
            string orderID  = temp5.ToString();
            int    noRooms  = Convert.ToInt32(temp6.ToString());
            double price    = Convert.ToDouble(temp7.ToString());

            s.setID(senderID);

            s.setAmt(amt); //OrderClass object set() methods
            s.setCardNo(cardNo);
            s.setOrderID(orderID);
            s.setPrice(price);
            s.setnoRooms(noRooms);
        }