// ----- BuyRecipe -------------------------------- // // Buy a recipe for a company // // ------------------------------------------------ public static void BuyRecipe() { // Variable declaration List <Recipe> recipeList = Recipe.GetAllRecipes(); int recipeIdx; Recipe selected; // List available recipes for (int i = 0; i < recipeList.Count; i++) { Console.WriteLine("{0}) ${2} | {1}", i + 1, recipeList[i].nm, recipeList[i].GetCost()); } // Prompt for user input recipeIdx = GetUserInput(recipeList.Count); if (recipeIdx == -1) { return; } selected = recipeList[recipeIdx]; // Charge the company's cash and add the recipe if (!company.Charge(selected.GetCost())) { Console.WriteLine("Insufficient funds."); Console.ReadKey(); return; } else { company.recipes.Add(selected); Console.WriteLine("Purchased \"{0}\" recipe.", selected.nm); Console.ReadKey(); } }