Ejemplo n.º 1
0
 public void orderProcessed(OrderObject order)
 {
     // write to console all details of the order that has processed.
     Console.WriteLine("\t\t\t##########   ORDER PROCESSED FOR CUSTOMER #{0}   ###########", order.getRecieverId());
     Console.WriteLine("\t\t\tTravel Agency {0} has processed the order for customer {1}. \n\t\t\t\tTicket Price = ${2}.\n\t\t\t\tAmount Ordered = {3}. \n\t\t\t\tTotal Cost = ${4}",
                       order.getSenderId(),
                       order.getRecieverId(),
                       order.getUnitPrice(),
                       order.getAmount(),
                       (order.getAmount() * order.getUnitPrice()));
     Console.WriteLine("\t\t\t###########################################################\n\n");
 }
Ejemplo n.º 2
0
        public static void processOrderFunc(OrderObject order)
        {
            //Compute the total cost of the purchase.
            int totalCost = order.getUnitPrice() * order.getAmount();

            //Check to make sure card is valid. The program is designed to generate invalid card numbers to show that error checking is working
            int cardNo = order.getCardNo();

            if (cardNo < 1500 || cardNo > 9500)
            {
                //If card is invalid, then display message. Also trigger the orderFailed event.
                Console.WriteLine("ERROR. INVALID CARD NO. {0}.\n PLEASE USE A DIFFERENT CARD\n", cardNo);
                orderFailed(cardNo);
                return;
            }
            else
            {
                orderProcessed(order);          //Trigger the orderProcessed event if the card number is correct.
            }
        }