public static OrderObject decrypt(String s)
 {
     Console.WriteLine(s);
     String[] items = s.Split('/');
     OrderObject order = new OrderObject(items[0], Convert.ToInt32(items[1]), items[2],
         Convert.ToInt32(items[3]), Convert.ToDouble(items[4]));
     /*order.setSenderID(items[0]);
     order.setCreditNum(Convert.ToInt32(items[1]));
     order.setReceiverID(items[2]);
     order.setAmount(Convert.ToInt32(items[3]));
     order.setPrice(Convert.ToInt32(items[4])); */
     return order;
 }
 // event handler
 // event handler that takes in the previous price and amount and the new price to calculate how many tickets should be bought
 public void ticketsOnSale(string airlineName, int prevAmt, double prevPrice, double newPrice)
 {
     int newAmt = (int)(prevPrice * prevAmt / newPrice); // calculate new amount by taking the cost of the order previously
                                                         // and divide it by the new price
         Int32 travelNum = rdm.Next(1, 6);
         OrderObject newOrder = new OrderObject(("travel agency " + (travelNum).ToString()), OrderObject.generateRandomCreditCardNo(),
             airlineName, newAmt, newPrice); // create new orderObject
         Console.WriteLine(Encoder.encrypt(newOrder));
         string encryptedObject = Encoder.encrypt(newOrder);
        // Program.rwlock.AcquireWriterLock(300);
         //try
       //  {
             Program.bufferRef.setOneCell(encryptedObject);
        // }
       //  finally
       //  {
        //     Program.rwlock.ReleaseWriterLock();
        // }
 }
        public void orderFunc(OrderObject order)
        {
            //start thread
            //check if card is valid
            int cardNo = order.getCardNum();

            // check if airline matches receiver ID
            if (cardNo >= 5000 && cardNo <= 7000)
            {
                //card is valid, process order
                double orderTotal = order.getUnitPrice() * order.getAmount() * .081; //(unit price * amount of tickets * sales tax)
                //Program.rwlock.AcquireWriterLock(300);
               // try
               // {
                    Program.confirm.setCell(order.getSenderID(), orderTotal);   // place the confirmation in the confirmation buffer
               // }
               // finally
              //  {
              //      Program.rwlock.ReleaseWriterLock();
              //  }
               // Monitor.PulseAll(Program.confirm);
            }
        }
 // static method that can be called anywhere to encrypt the object into a string value
 public static string encrypt(OrderObject oo)
 {
     // string encryption as follows: <senderID>/<card number>/<receiverID>/<amount of tickets>/<unit price
     string encrypted = oo.getSenderID() + "/" + oo.getCardNum() + "/" + oo.getReceiverID() + "/" + oo.getAmount() + "/" + oo.getUnitPrice();
     return encrypted;
 }