Example #1
0
        //event handler for price cuts
        //creates order
        public void bookOnSale(double price, string pubId)
        {
            Int32 numBooks;

            if (price <= 75)
            {
                numBooks = 100;
            }
            else if (price > 75 && price < 150)
            {
                numBooks = 50;
            }
            else
            {
                numBooks = 25;
            }
            orderCount++;
            OrderClass order = new OrderClass(id, cardNumber, pubId, numBooks, price, orderCount);
            string     obj   = Coders.encode(order);


            mb.setObject(obj);
            Console.WriteLine("ORDER {3}: Bookstore {0} is creating an order for {1} books from Publisher {2} at {4}", id, numBooks, pubId, order.getOrderNumber(), order.getTimeStamp());
            orderCreated();
        }
Example #2
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());
            }
        }