Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }