Example #1
0
        public void OrderProcessing()
        {
            string encodedString = mb.getObject(id);

            //check to see if the retrieved object pertains to the current publisher
            //if so, process order
            if (encodedString != "ERROR")
            {
                OrderClass order = Coders.decode(encodedString);
                Console.WriteLine("Publisher {0} is processing order {1} sent from Bookstore {2}", order.getRecieverID(), order.getOrderNumber(), order.getSenderId());

                double totalCharge = (order.getUnitPrice() * order.getAmount()) * (1 + taxPercent) + getLocCharge();
                string validity    = Bank.validate(order.getCardNo(), totalCharge);

                if (validity == "valid")
                {
                    numBooks -= order.getAmount();
                }
                callBack(validity, order.getSenderId());
            }
        }
Example #2
0
        /*
         * Encoder is a class or a method in a class: The Encoder will convert an OrderObject into a string. You
         * can choose any way to encode the values into a string, as long as you can decode the string back to the
         * original order object
         */

        public static string encode(OrderClass obj)
        {
            string encode;

            encode = obj.getSenderId() + "," + obj.getCardNo().ToString() + ",PUBID:" + obj.getRecieverID() + "," + obj.getAmount().ToString() + "," + obj.getUnitPrice().ToString() + "," + obj.getTimeStamp() + "," + obj.getOrderNumber();


            return(encode);
        }