Litt Codealong
This commit is contained in:
parent
9adcac365a
commit
e8146138e7
16
Codealong/CodeAlong0412/CodeAlong0412.sln
Normal file
16
Codealong/CodeAlong0412/CodeAlong0412.sln
Normal file
|
@ -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
|
10
Codealong/CodeAlong0412/CodeAlong0412/CodeAlong0412.csproj
Normal file
10
Codealong/CodeAlong0412/CodeAlong0412/CodeAlong0412.csproj
Normal file
|
@ -0,0 +1,10 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
37
Codealong/CodeAlong0412/CodeAlong0412/Program.cs
Normal file
37
Codealong/CodeAlong0412/CodeAlong0412/Program.cs
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
36
Codealong/CodeAlong0412/CodeAlong0412/recepies.cs
Normal file
36
Codealong/CodeAlong0412/CodeAlong0412/recepies.cs
Normal file
|
@ -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
|
Loading…
Reference in a new issue