From 62b9bfb0fdabb1e28ff64652ecfa560ddf9522d7 Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Wed, 20 Nov 2024 12:52:38 +0100 Subject: [PATCH] Objects and Enums test --- Emne 3/ObjectsAndEnums/Box.cs | 15 ++++++++++ Emne 3/ObjectsAndEnums/DaysOfWeek.cs | 12 ++++++++ Emne 3/ObjectsAndEnums/ObjectsAndEnums.csproj | 10 +++++++ Emne 3/ObjectsAndEnums/ObjectsAndEnums.sln | 16 ++++++++++ Emne 3/ObjectsAndEnums/Program.cs | 29 +++++++++++++++++++ Emne 3/Pokemon/Pokemon.csproj | 10 +++++++ Emne 3/Pokemon/Pokemon.sln | 16 ++++++++++ Emne 3/Pokemon/Program.cs | 1 + 8 files changed, 109 insertions(+) create mode 100644 Emne 3/ObjectsAndEnums/Box.cs create mode 100644 Emne 3/ObjectsAndEnums/DaysOfWeek.cs create mode 100644 Emne 3/ObjectsAndEnums/ObjectsAndEnums.csproj create mode 100644 Emne 3/ObjectsAndEnums/ObjectsAndEnums.sln create mode 100644 Emne 3/ObjectsAndEnums/Program.cs create mode 100644 Emne 3/Pokemon/Pokemon.csproj create mode 100644 Emne 3/Pokemon/Pokemon.sln create mode 100644 Emne 3/Pokemon/Program.cs diff --git a/Emne 3/ObjectsAndEnums/Box.cs b/Emne 3/ObjectsAndEnums/Box.cs new file mode 100644 index 0000000..0f78f49 --- /dev/null +++ b/Emne 3/ObjectsAndEnums/Box.cs @@ -0,0 +1,15 @@ +namespace ObjectsAndEnums +{ + + public class Box + { + public int Width; + public int Height; + + internal void Show() + { + Console.WriteLine("Boksen har disse målene: " + Width + "x" + Height); + } + + } +} \ No newline at end of file diff --git a/Emne 3/ObjectsAndEnums/DaysOfWeek.cs b/Emne 3/ObjectsAndEnums/DaysOfWeek.cs new file mode 100644 index 0000000..e798131 --- /dev/null +++ b/Emne 3/ObjectsAndEnums/DaysOfWeek.cs @@ -0,0 +1,12 @@ +namespace ObjectsAndEnums; + +public enum DaysOfWeek +{ + Monday, + Tuesday, + Wednesday, + Thursday, + Friday, + Saturday, + Sunday, +} \ No newline at end of file diff --git a/Emne 3/ObjectsAndEnums/ObjectsAndEnums.csproj b/Emne 3/ObjectsAndEnums/ObjectsAndEnums.csproj new file mode 100644 index 0000000..2f4fc77 --- /dev/null +++ b/Emne 3/ObjectsAndEnums/ObjectsAndEnums.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Emne 3/ObjectsAndEnums/ObjectsAndEnums.sln b/Emne 3/ObjectsAndEnums/ObjectsAndEnums.sln new file mode 100644 index 0000000..fe92620 --- /dev/null +++ b/Emne 3/ObjectsAndEnums/ObjectsAndEnums.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ObjectsAndEnums", "ObjectsAndEnums.csproj", "{987031C2-BDA2-4A1D-941F-DCB9C06DD053}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {987031C2-BDA2-4A1D-941F-DCB9C06DD053}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {987031C2-BDA2-4A1D-941F-DCB9C06DD053}.Debug|Any CPU.Build.0 = Debug|Any CPU + {987031C2-BDA2-4A1D-941F-DCB9C06DD053}.Release|Any CPU.ActiveCfg = Release|Any CPU + {987031C2-BDA2-4A1D-941F-DCB9C06DD053}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Emne 3/ObjectsAndEnums/Program.cs b/Emne 3/ObjectsAndEnums/Program.cs new file mode 100644 index 0000000..8a5cc39 --- /dev/null +++ b/Emne 3/ObjectsAndEnums/Program.cs @@ -0,0 +1,29 @@ +namespace ObjectsAndEnums +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("Tester Klasser og Enums"); + var box = new Box(); + box.Width = 100; + box.Height = 100; + box.Show(); + DaysOfWeek day = DaysOfWeek.Monday; + + switch (day) + { + case DaysOfWeek.Monday: + Console.WriteLine("Monday"); + break; + case DaysOfWeek.Tuesday: + Console.WriteLine("Tuesday"); + break; + default: Console.WriteLine("Unknown day"); + break; + + } + } + } +} + diff --git a/Emne 3/Pokemon/Pokemon.csproj b/Emne 3/Pokemon/Pokemon.csproj new file mode 100644 index 0000000..2f4fc77 --- /dev/null +++ b/Emne 3/Pokemon/Pokemon.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Emne 3/Pokemon/Pokemon.sln b/Emne 3/Pokemon/Pokemon.sln new file mode 100644 index 0000000..da09f6b --- /dev/null +++ b/Emne 3/Pokemon/Pokemon.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pokemon", "Pokemon.csproj", "{B5E5E3C3-6454-46D3-848D-7DE15A01B6A2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B5E5E3C3-6454-46D3-848D-7DE15A01B6A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B5E5E3C3-6454-46D3-848D-7DE15A01B6A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B5E5E3C3-6454-46D3-848D-7DE15A01B6A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B5E5E3C3-6454-46D3-848D-7DE15A01B6A2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Emne 3/Pokemon/Program.cs b/Emne 3/Pokemon/Program.cs new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Emne 3/Pokemon/Program.cs @@ -0,0 +1 @@ + \ No newline at end of file