/*calulates the no of rooms based on the price difference and the need
         calls the encoder to encode the order and places the order in the buffer*/
        public void calcRooms(int i, float newPrice)
        {
            try
            {

                int need = rng.Next(0, 5);
                int maxRoomPriceDiff = 5000;
                float diff = currentPrice[i] - newPrice;
                currentPrice[i] = newPrice;

                float fraction = (diff + maxRoomPriceDiff) / (2 * maxRoomPriceDiff);
                int rooms = (Int32)Math.Round(fraction * need);
                if (rooms == 0)
                    return;
                o1 = new Order();
                int tempOrder = ++orderId;
                o1.setOrder(agencyId, cardNo, h[i].getHotelId(), rooms, tempOrder, newPrice);
                String buffer_str = EncoderDecoder.encode(o1);
                pendingReciept++;//increment the pending reciept with every order that is placed in buffer
                Buffer.setBuffer(buffer_str, agencyId, h[i].getHotelId(), tempOrder, newPrice);

                Thread.Sleep(rng.Next(400, 600));
                return;

            }
            catch (Exception e)
            {

                Console.WriteLine(e.Message);
            }
        }