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 void createOrderObject(string threadId, int price, string receiver)  //Create an order object
        {
            //Order object needs the following:
            //senderId
            //cardNo
            //receiverId
            //amount
            //unit price

            string senderId   = threadId;              //SenderId is the thread name of the travel agency
            int    cardNo     = rand.Next(1000, 9999); //creates a random card number. If the card # is between 2000 and 9000 it is valid.
            string receiverId = receiver;              //ReceiverId customer number or the ordercount number that is initialized in Program.cs
            int    amount     = rand.Next(1, 10);      //Generates a random number of tickets the buyer will buy.
            int    unitPrice  = price;                 //Unit price is the current ticket price

            //generate an order object
            OrderObject order = new OrderObject(senderId, cardNo, receiverId, amount, unitPrice);

            //take the order object and put it in the multi cell buffer
            Program.orderBuffer.setBuffer(order);
            newOrderCreated(order.getRecieverId());                      //Trigger the order created event so that processing can begin
        }