public static void processingThread(OrderClass order, int price) { total_amount = price * order.getAmount(); if (order.getCardNo() < 1000 || order.getCardNo() > 10000) { total_amount = 0.0; Console.WriteLine("Unacceptable card number"); } }
public static double processOrder(OrderClass order, int price) { Thread procThread = new Thread(() => processingThread(order, price)); procThread.Start(); Thread.Sleep(1000); procThread.Join(); Console.WriteLine("\nOrder Received from Travel Agency " + Convert.ToString(order.getSenderId()) + " for Hotel Supplier " + Convert.ToString(order.getReceiverID()) + " for " + Convert.ToString(order.getAmount()) + " rooms"); Console.WriteLine("Amount Charged = " + total_amount + "\n"); orderCompleted(order.getSenderId(), order.getReceiverID()); return(total_amount); }
public void agencyThread(int agency_id, int cardNo) { this.agency_id = agency_id; while (supplierActive) { while (!priceCut) { } int rooms = numberOfRoomsToOrder(); OrderClass order = new OrderClass(agency_id, cardNo, supplier_id, rooms); string encoded = Encoder.Encode(order); t1 = DateTime.Now; Program.bo.setOneCell(encoded); priceCut = false; Thread.Sleep(1000); } }
public static string Encode(OrderClass order) { string s = order.getSenderId().ToString() + "," + order.getCardNo().ToString() + "," + order.getReceiverID().ToString() + "," + order.getAmount().ToString(); return(s); }