Litt CodeAlong

This commit is contained in:
Geir Okkenhaug Jerstad 2024-12-04 14:53:19 +01:00
parent e8146138e7
commit 9c08b65735
3 changed files with 52 additions and 27 deletions

View file

@ -0,0 +1,50 @@
namespace CodeAlong0412;
public class App
{
List<Dish> _dish;
public App()
{
_dish = new List<Dish>()
{
new Dish("Brød", "Loff", ["Mel",]),
new Dish("Grøt", "Rømmegrøt", ["Milk","Rømme","Ris"]),
new Dish("Pannekaker","Pannekaker er godt", ["Milk","Mel","Egg","Sukker"]),
};
AppMenu();
}
void AppMenu()
{
var running = true;
while (running)
{
//Console.Clear();
Console.WriteLine("Welcome to the Dishshower!!");
Console.WriteLine("1. Dish List");
var input = Console.ReadLine();
switch(input)
{
case "1":
ShowDishNames();
Thread.Sleep(10000);
break;
case "2":
//var input = Console.ReadLine();
//SearchIngredients();
running = false;
break;
}
}
}
private void ShowDishNames()
{
foreach (var dish in _dish)
{
Console.WriteLine(dish.NameOfDish);
}
Console.WriteLine(":-D");
}
}

View file

@ -6,32 +6,8 @@
*/ */
using CodeAlong0412; using CodeAlong0412;
var dish1 = new Dish("Bread", "Loff", ["Mel","Vann","Smør"]); new App();
var dish2 = new Dish("Grøt","Rømmegrøt",["Ris","Rømme","Melk","Smør"]);
var dishList = {dish1, dish2};
var running = true;
while (running)
{
Console.Clear();
Console.WriteLine("Welcome to the Dishshower!!");
Console.WriteLine("1. Dish List");
var input = Console.ReadLine();
switch(input)
{
case "1":
foreach (var dish in dishList)
{
Console.WriteLine(dish.NameOfDish);
}
Console.WriteLine();
break;
case "2":
//var input = Console.ReadLine();
//SearchIngredients();
break;
}
}

View file

@ -11,7 +11,7 @@ public class Dish
{ {
NameOfDish = name; NameOfDish = name;
DescriptionOfDish = description; DescriptionOfDish = description;
this.Ingredients = ingredients; Ingredients = ingredients;
} }
public void ShowDish() public void ShowDish()
@ -32,5 +32,4 @@ public class Dish
} }
// search // search