public String ProcessOrder(OrderObject order) { bool isValidCardno = false; int numRooms = order.getAmount(); Console.WriteLine("Checking card validity"); // Check validity of cardNo long cardNo = order.getCardNo(); if (cardNo > 5000000000000000 && cardNo < 7000000000000000) { isValidCardno = true; } if (isValidCardno) { Console.WriteLine("\tCardNo is valid"); if (numRooms <= this.capacity) { this.capacity -= numRooms; Console.WriteLine(String.Format("\tCost per room = {0}", hotelPrice)); // Time between order placed and order processed TimeSpan timeToProcessOrder = DateTime.Now - order.getOrderPlacedTime(); return(String.Format("ORDER CONFIRMED - Total amount = {0}, order process time = {1} milliseconds", numRooms * hotelPrice, timeToProcessOrder.Milliseconds)); } else { return("ORDER DECLINED - There are no sufficient rooms in this hotel"); } } else { return("ORDER DECLINED - Card is invalid"); } }
// Convert the object into a string public static string Encode(OrderObject orderObj) { return(String.Format("{0}|{1}|{2}|{3}|{4}", orderObj.getSenderId(), orderObj.getSupplierId(), orderObj.getCardNo(), orderObj.getAmount(), orderObj.getOrderPlacedTime())); }