diff --git a/Emne 3/Clicker/Clicker.sln b/Emne 3/Clicker/Clicker.sln new file mode 100644 index 0000000..19694bb --- /dev/null +++ b/Emne 3/Clicker/Clicker.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Clicker", "Clicker\Clicker.csproj", "{872462F6-2D43-4833-ADDD-01F7115DD1F5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {872462F6-2D43-4833-ADDD-01F7115DD1F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {872462F6-2D43-4833-ADDD-01F7115DD1F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {872462F6-2D43-4833-ADDD-01F7115DD1F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {872462F6-2D43-4833-ADDD-01F7115DD1F5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Emne 3/Clicker/Clicker/Clicker.csproj b/Emne 3/Clicker/Clicker/Clicker.csproj new file mode 100644 index 0000000..2f4fc77 --- /dev/null +++ b/Emne 3/Clicker/Clicker/Clicker.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Emne 3/Clicker/Clicker/Person.cs b/Emne 3/Clicker/Clicker/Person.cs new file mode 100644 index 0000000..2516bbc --- /dev/null +++ b/Emne 3/Clicker/Clicker/Person.cs @@ -0,0 +1,13 @@ +namespace Clicker; + +public class Person +{ + public string Name { get; set; } + public int Points { get; set; } + + public Person(string name, int points) + { + Name = name; + Points = points; + } +} \ No newline at end of file diff --git a/Emne 3/Clicker/Clicker/Program.cs b/Emne 3/Clicker/Clicker/Program.cs new file mode 100644 index 0000000..8f37a57 --- /dev/null +++ b/Emne 3/Clicker/Clicker/Program.cs @@ -0,0 +1,45 @@ +using System.Text.Json; + +namespace Clicker +{ + internal class StaticClicker + { + + + public static void Main() + { + var json = File.ReadAllText("test.json"); + var people = JsonSerializer.Deserialize(json, options); + var clickers = new Clicker[] + { + new Clicker('a'), + new Clicker('b'), + }; + while (true) + { + Console.Clear(); + + Console.WriteLine($"Klikker A: Du har {Points} poeng. a + poeng A upgrade"); + var cmdKey = Console.ReadKey(true); + HandleCommand(cmdKey); + } + } + + public static void HandleCommand(cmdKey) + { + if (cmdKey.KeyChar == 'a') + { + _points += _upgrades; + } + else if (cmdKey.KeyChar == 'A') + { + if (_points >= 10) + { + _upgrades++; + _points -= 10; + } + } + } + + } +} \ No newline at end of file diff --git a/Emne 3/Clicker/Clicker/clickerSimple.cs b/Emne 3/Clicker/Clicker/clickerSimple.cs new file mode 100644 index 0000000..213dde9 --- /dev/null +++ b/Emne 3/Clicker/Clicker/clickerSimple.cs @@ -0,0 +1,27 @@ +namespace Clicker; + +internal class Clicker +{ + public int Points; + public int Upgrades; + public char Character; + + public Clicker(char character) + { + Upgrades = 1; + Points = 0; + Character = character; + } + + public void Show() + { + Console.Clear(); + Console.WriteLine($"Clicker Simple. Du har {Points} points."); + } + + public void HandleCommand(ConsoleKey cmdKey) + { + + } + +} \ No newline at end of file diff --git a/Emne 3/Clicker/Clicker/test.json b/Emne 3/Clicker/Clicker/test.json new file mode 100644 index 0000000..a75104c --- /dev/null +++ b/Emne 3/Clicker/Clicker/test.json @@ -0,0 +1,10 @@ +[ +{ + Name: "John", + Points: 112 +}, +{ + Name: "Per", + Points: 45 +} +] \ No newline at end of file