示例#1
0
        public static void processOrder(object _order)
        {
            OrderClass order = (OrderClass)_order;             //cast to order object

            if (validateCreditCard(order.getSenderId(), order.getCardNo()))
            {
                order.setTotalAmount(totalChargeAmount(order.getAmount(), order.getPrice()));
                order.setOrderConfirmedDate(DateTime.Now);
                orderConfirmation(order);                 //confirms the orders
            }
            else
            {
                Console.WriteLine("Invalid Credit Card Number. Order not confirmed.");
            }
        }
        public string encode(OrderClass order)
        {
            //Converts Order Object into a string
            string encodedString = "";

            encodedString += order.getSenderId();
            encodedString += "+";             //terminal token
            encodedString += order.getAmount();
            encodedString += "+";             //terminal token
            encodedString += order.getCardNo();
            encodedString += "+";             //terminal token
            encodedString += order.getOrderDate();
            encodedString += "+";             //terminal token
            encodedString += order.getPrice();
            return(encodedString);
        }