From e8146138e727271e264ecfa85448baae0b64d654 Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Wed, 4 Dec 2024 13:34:04 +0100 Subject: [PATCH] Litt Codealong --- Codealong/CodeAlong0412/CodeAlong0412.sln | 16 ++++++++ .../CodeAlong0412/CodeAlong0412.csproj | 10 +++++ .../CodeAlong0412/CodeAlong0412/Program.cs | 37 +++++++++++++++++++ .../CodeAlong0412/CodeAlong0412/recepies.cs | 36 ++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 Codealong/CodeAlong0412/CodeAlong0412.sln create mode 100644 Codealong/CodeAlong0412/CodeAlong0412/CodeAlong0412.csproj create mode 100644 Codealong/CodeAlong0412/CodeAlong0412/Program.cs create mode 100644 Codealong/CodeAlong0412/CodeAlong0412/recepies.cs diff --git a/Codealong/CodeAlong0412/CodeAlong0412.sln b/Codealong/CodeAlong0412/CodeAlong0412.sln new file mode 100644 index 0000000..17f82a6 --- /dev/null +++ b/Codealong/CodeAlong0412/CodeAlong0412.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAlong0412", "CodeAlong0412\CodeAlong0412.csproj", "{1D9133E7-E060-419E-B475-AC10729FDD0B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1D9133E7-E060-419E-B475-AC10729FDD0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1D9133E7-E060-419E-B475-AC10729FDD0B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1D9133E7-E060-419E-B475-AC10729FDD0B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1D9133E7-E060-419E-B475-AC10729FDD0B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Codealong/CodeAlong0412/CodeAlong0412/CodeAlong0412.csproj b/Codealong/CodeAlong0412/CodeAlong0412/CodeAlong0412.csproj new file mode 100644 index 0000000..2f4fc77 --- /dev/null +++ b/Codealong/CodeAlong0412/CodeAlong0412/CodeAlong0412.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Codealong/CodeAlong0412/CodeAlong0412/Program.cs b/Codealong/CodeAlong0412/CodeAlong0412/Program.cs new file mode 100644 index 0000000..60c9f16 --- /dev/null +++ b/Codealong/CodeAlong0412/CodeAlong0412/Program.cs @@ -0,0 +1,37 @@ +/* Du skal lage en oppskriftsapp der brukeren kan velge å: + Se alle oppskrifter som er tilgjengelig, + Filtrere oppskrift basert på kategori; ex vegetar, helgekos, + Filtrere oppskriftene ved å søke etter oppskrifter som inneholder en spesifikk ingrediens + Brukeren skal kunne velge å se nærmere på en oppskrift for å få ingredienser og fremgangsmetode +*/ +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}; + + +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 new file mode 100644 index 0000000..fce705f --- /dev/null +++ b/Codealong/CodeAlong0412/CodeAlong0412/recepies.cs @@ -0,0 +1,36 @@ +namespace CodeAlong0412; + +public class Dish +{ + + public string NameOfDish { get; set; } + public string DescriptionOfDish { get; set; } + public string[] Ingredients { get; set; } + + public Dish(string name, string description, string[] ingredients) + { + NameOfDish = name; + DescriptionOfDish = description; + this.Ingredients = ingredients; + } + + public void ShowDish() + { + Console.WriteLine($"\nNavn: {NameOfDish}\nBeskrivelse: {DescriptionOfDish}\n"); + Console.WriteLine($"Ingredients: \n{ShowIngredients(Ingredients)}"); + } + + public string ShowIngredients(string[] ingredientArray) + { + var items = ""; + foreach (var ingredient in ingredientArray) + { + items += ingredient + "\n"; + } ; + return items; + } + + +} + +// search