Terjes Clicker start
This commit is contained in:
parent
558073a24d
commit
02e0b0815f
16
Emne 3/Clicker/Clicker.sln
Normal file
16
Emne 3/Clicker/Clicker.sln
Normal file
|
@ -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
|
10
Emne 3/Clicker/Clicker/Clicker.csproj
Normal file
10
Emne 3/Clicker/Clicker/Clicker.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>
|
13
Emne 3/Clicker/Clicker/Person.cs
Normal file
13
Emne 3/Clicker/Clicker/Person.cs
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
45
Emne 3/Clicker/Clicker/Program.cs
Normal file
45
Emne 3/Clicker/Clicker/Program.cs
Normal file
|
@ -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<Person[]>(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
27
Emne 3/Clicker/Clicker/clickerSimple.cs
Normal file
27
Emne 3/Clicker/Clicker/clickerSimple.cs
Normal file
|
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
10
Emne 3/Clicker/Clicker/test.json
Normal file
10
Emne 3/Clicker/Clicker/test.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
[
|
||||
{
|
||||
Name: "John",
|
||||
Points: 112
|
||||
},
|
||||
{
|
||||
Name: "Per",
|
||||
Points: 45
|
||||
}
|
||||
]
|
Loading…
Reference in a new issue