Example #1
0
 public void travelAgentfunction()
 {
     //HotelSupplier hs = new HotelSupplier();
     for (Int32 i = 0; i < 10; i++)
     {
         Thread.Sleep(500);
         Int32 p = HotelSupplier.getPrice();
         Console.WriteLine("Hotel{0} has everyday low price: ${1} each", Thread.CurrentThread.Name, p);
     }
 }
Example #2
0
        public void pricingModel() //to generate a random price
        {
            for (Int32 i = 0; i < 50; i++)
            {
                Thread.Sleep(500);

                Int32 p = rng.Next(5, 10);
                HotelSupplier.changePrice(p);
            }
        }
Example #3
0
        public void orderProcessMethod()
        {
            unitPrice = HotelSupplier.getPrice();
            int priceOfRooms = unitPrice * numOfRooms;

            totalAmount = priceOfRooms + (int)(priceOfRooms * tax) + locationCharge;

            //call Bank Service to validate the credit card
            creditCardValidityStatus = "Valid";

            Console.WriteLine("Order Received by Thread ID - " + receiverId + "\n" + "Order Placed by Thread ID - " + senderId + "\n" + "No. of rooms = " + numOfRooms +
                              "\n" + "Credit Card Number = " + cardNo + "\n" + "Total Amount of Charge = " + totalAmount + "\n" + "Credi Card Validity Status = " + creditCardValidityStatus + "\n");
        }
Example #4
0
        public void Main(String[] args)
        {
            HotelSupplier hotel   = new HotelSupplier();
            Thread        pricing = new Thread(new ThreadStart(hotel.pricingModel));

            pricing.Start();
            TravelAgent agent = new TravelAgent();

            HotelSupplier.priceCut += new PriceCutEvent(agent.discountPrice);
            Thread[] agents = new Thread[5];
            for (int i = 0; i < 5; i++)
            {   // Start 5 agent threads
                agents[i]      = new Thread(new   ThreadStart(agent.travelAgentfunction));
                agents[i].Name = (i + 1).ToString();
                agents[i].Start();
            }
        }