//copy constructor public DeliveryOrder(DeliveryOrder newList) { foreach (var item in newList.DeliveryOrderTable) { DeliveryOrderIndividual newOrder; newList.DeliveryOrderTable.TryGetValue(item.Key, out newOrder); this.addDeliveryOrder(newOrder); } }
static void Main(string[] args) { //================================================================================== // instances of costumer accounts CostList = new CustomerAccount("sam", "89012345", "*****@*****.**"); CostList.addNewCostumerAccount("john", "56789012", "*****@*****.**"); CostList.addNewCostumerAccount("Jane", "45678901", "*****@*****.**"); CostList.addNewCostumerAccount("alex", "23456789", "*****@*****.**"); CostList.addNewCostumerAccount("steve", "12345678", "*****@*****.**"); CostList.printcostumerTable(); //================================================================================== // instances of orders Console.WriteLine(); DeliverOrderList = new DeliveryOrder("pencil", 20, 10.00, "sam", 7777); DeliverOrderList.createOrder("book", 1, 50.00, "john", 5555); DeliverOrderList.createOrder("note", 3, 20.00, "alex", 3333); DeliverOrderList.printOrdersTable(); bool run = true; int yes; //program starts makeOrders = new PurchaseOrderManager(); Console.WriteLine(); while (run) { Console.WriteLine("Please enter the accountID:"); string accountID = Console.ReadLine(); Console.WriteLine("Please enter the item:"); string item = Console.ReadLine(); Console.WriteLine("Please enter quantity (only numbers):"); int quantity = int.Parse(Console.ReadLine()); //if (quantity < 0) quantity = -quantity; Console.WriteLine("Please enter the totalPrice(only numbers, integers or decimals):"); string newPrice = Console.ReadLine(); double totalPrice = double.Parse(newPrice); CustomerInterface.request(item, quantity, totalPrice, accountID); Console.WriteLine("Do you want to start a new order? Enter 1 for yes or 0 for no"); yes = int.Parse(Console.ReadLine()); run = (yes == 1) ? true : false; Console.WriteLine(); } makeOrders.DeliverOrderTable.printOrdersTable(); Console.WriteLine(); Console.WriteLine("You've reached the end of the program."); }
} //end of requestorder //constructor copies the test dictionary with previous // orders to the obj within this class public PurchaseOrderManager() { this.DeliverOrderTable = DeliverOrderList; }