|
|
@ -2,7 +2,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
using ConsoleApp;
|
|
|
|
using ConsoleApp;
|
|
|
|
using Model;
|
|
|
|
using Model;
|
|
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Hello, World!\n\n");
|
|
|
|
Console.WriteLine("Hello, World!\n\n");
|
|
|
|
|
|
|
|
|
|
|
@ -14,8 +14,44 @@ Stub stub = new Stub();
|
|
|
|
List<Recipe> recipes = stub.LoadRecipes();
|
|
|
|
List<Recipe> recipes = stub.LoadRecipes();
|
|
|
|
List<RecipeCollection> recipeCollections = stub.LoadRecipeCollection();
|
|
|
|
List<RecipeCollection> recipeCollections = stub.LoadRecipeCollection();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (Recipe r in recipes)
|
|
|
|
RecipeCollection? allRecipe = recipeCollections.Find(x => x.Description.Equals("All"));
|
|
|
|
Console.WriteLine(r);
|
|
|
|
if (allRecipe == null)
|
|
|
|
|
|
|
|
throw new ArgumentException("Load AllRecipe in stub: can't find 'All'.");
|
|
|
|
foreach (RecipeCollection r in recipeCollections)
|
|
|
|
|
|
|
|
Console.WriteLine(r);
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
ResearchMenuRecipe researchMenu = new ResearchMenuRecipe();
|
|
|
|
|
|
|
|
Recipe[] result = allRecipe.ResearchByName(sb.ToString());
|
|
|
|
|
|
|
|
researchMenu.UpdateDisplay(sb.ToString(), result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ConsoleKeyInfo cki;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cki = Console.ReadKey(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (cki.Key)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case ConsoleKey.UpArrow:
|
|
|
|
|
|
|
|
researchMenu.SelectPrevioustLine();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ConsoleKey.DownArrow:
|
|
|
|
|
|
|
|
researchMenu.SelectNextLine();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ConsoleKey.Backspace:
|
|
|
|
|
|
|
|
if (sb.Length > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sb.Remove(sb.Length - 1, 1);
|
|
|
|
|
|
|
|
result = allRecipe.ResearchByName(sb.ToString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
sb.Append(cki.KeyChar);
|
|
|
|
|
|
|
|
result = allRecipe.ResearchByName(sb.ToString());
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
researchMenu.UpdateDisplay(sb.ToString(), result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} while (cki.Key != ConsoleKey.Enter);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(researchMenu.ReturnSelected());
|