public SingleBox Add(string name, string nameOfBox, DateTime deliveryDate) { SingleBox newBox = new SingleBox(); newBox.Name = name; newBox.NameOfBox = nameOfBox; newBox.DeliveryDate = deliveryDate; Add(newBox); return(newBox); }
public void Add(SingleBox box) { boxes.Add(box); }
public void AddProductsToBox(SingleBox box) { bool addAnother = false; do { Console.WriteLine("\nOur farm products:\n"); List <string> options = FarmProducts.Options(); int optionIndex = 1; foreach (string option in options) { Console.WriteLine(optionIndex + " " + option); optionIndex++; } Console.Write("\nWhat would you like to add to your box? (Please type in the number or \"ABORT\" to exit.) "); string optionNum = Console.ReadLine(); if (optionNum.Equals("abort", StringComparison.OrdinalIgnoreCase)) { return; } if (ValidateProductIndexEntry(optionNum, out int result)) { do { Console.Write("\nHow many would you like? (Or, type in \"ABORT\" to exit.) "); string numOfChosenItem = Console.ReadLine(); if (numOfChosenItem.Equals("abort", StringComparison.OrdinalIgnoreCase)) { return; } if (ValidateNumberOfItemsRequested(numOfChosenItem, out int numOfItem)) { string newProductValue = options[result - 1]; box.Add_Product(newProductValue, numOfItem); Console.WriteLine($"\nYour item {newProductValue} has been successfully added."); Console.Write("\nWould you like to add another item to your box? "); string addAnotherItemYesOrNo = Console.ReadLine(); if (addAnotherItemYesOrNo.Equals("yes", StringComparison.OrdinalIgnoreCase)) { addAnother = true; } else if (addAnotherItemYesOrNo.Equals("no", StringComparison.OrdinalIgnoreCase)) { Console.WriteLine("\nYou have the following items in your box:"); foreach (CSABoxProduct product in box.ProductList) { Console.WriteLine($"{product.ProductName}, {product.ProductQuantity}"); } addAnother = false; } break; } } while (true); } else { addAnother = true; } } while (addAnother); }