From 9c08b657359a45935eee7b24f5f1363e5931c529 Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Wed, 4 Dec 2024 14:53:19 +0100 Subject: [PATCH] Litt CodeAlong --- Codealong/CodeAlong0412/CodeAlong0412/App.cs | 50 +++++++++++++++++++ .../CodeAlong0412/CodeAlong0412/Program.cs | 26 +--------- .../CodeAlong0412/CodeAlong0412/recepies.cs | 3 +- 3 files changed, 52 insertions(+), 27 deletions(-) create mode 100644 Codealong/CodeAlong0412/CodeAlong0412/App.cs diff --git a/Codealong/CodeAlong0412/CodeAlong0412/App.cs b/Codealong/CodeAlong0412/CodeAlong0412/App.cs new file mode 100644 index 0000000..ea80cb2 --- /dev/null +++ b/Codealong/CodeAlong0412/CodeAlong0412/App.cs @@ -0,0 +1,50 @@ +namespace CodeAlong0412; + +public class App +{ + List _dish; + + public App() + { + _dish = new List() + { + 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"); + } +} \ No newline at end of file diff --git a/Codealong/CodeAlong0412/CodeAlong0412/Program.cs b/Codealong/CodeAlong0412/CodeAlong0412/Program.cs index 60c9f16..87c86c4 100644 --- a/Codealong/CodeAlong0412/CodeAlong0412/Program.cs +++ b/Codealong/CodeAlong0412/CodeAlong0412/Program.cs @@ -6,32 +6,8 @@ */ using CodeAlong0412; -var dish1 = new Dish("Bread", "Loff", ["Mel","Vann","Smør"]); -var dish2 = new Dish("Grøt","Rømmegrøt",["Ris","Rømme","Melk","Smør"]); -var dishList = {dish1, dish2}; +new App(); -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; - } -} diff --git a/Codealong/CodeAlong0412/CodeAlong0412/recepies.cs b/Codealong/CodeAlong0412/CodeAlong0412/recepies.cs index fce705f..b0f0aee 100644 --- a/Codealong/CodeAlong0412/CodeAlong0412/recepies.cs +++ b/Codealong/CodeAlong0412/CodeAlong0412/recepies.cs @@ -11,7 +11,7 @@ public class Dish { NameOfDish = name; DescriptionOfDish = description; - this.Ingredients = ingredients; + Ingredients = ingredients; } public void ShowDish() @@ -32,5 +32,4 @@ public class Dish } - // search