MSSwitch
This commit is contained in:
parent
15bf38744f
commit
37e271fd9e
16
Emne 3/ConsoleApp8/ConsoleApp8.sln
Normal file
16
Emne 3/ConsoleApp8/ConsoleApp8.sln
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwitchMS", "SwitchMS\SwitchMS.csproj", "{ED133C88-3CE5-4506-8170-0D6D79F1403E}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{ED133C88-3CE5-4506-8170-0D6D79F1403E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{ED133C88-3CE5-4506-8170-0D6D79F1403E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{ED133C88-3CE5-4506-8170-0D6D79F1403E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{ED133C88-3CE5-4506-8170-0D6D79F1403E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
35
Emne 3/ConsoleApp8/SwitchMS/Program.cs
Normal file
35
Emne 3/ConsoleApp8/SwitchMS/Program.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
public static class SwitchMS
|
||||||
|
{
|
||||||
|
public enum Direction
|
||||||
|
{
|
||||||
|
Up,
|
||||||
|
Down,
|
||||||
|
Right,
|
||||||
|
Left
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Orientation
|
||||||
|
{
|
||||||
|
North,
|
||||||
|
South,
|
||||||
|
East,
|
||||||
|
West
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Orientation ToOrientation(Direction direction) => direction switch
|
||||||
|
{
|
||||||
|
Direction.Up => Orientation.North,
|
||||||
|
Direction.Right => Orientation.East,
|
||||||
|
Direction.Down => Orientation.South,
|
||||||
|
Direction.Left => Orientation.West,
|
||||||
|
_ => throw new ArgumentOutOfRangeException(nameof(direction), $"Not expected direction value: {direction}"),
|
||||||
|
};
|
||||||
|
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
var direction = Direction.Up;
|
||||||
|
Console.WriteLine($"Map view direction is {direction}");
|
||||||
|
Console.WriteLine($"Cardinal orientation is {ToOrientation(direction)}");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
10
Emne 3/ConsoleApp8/SwitchMS/SwitchMS.csproj
Normal file
10
Emne 3/ConsoleApp8/SwitchMS/SwitchMS.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>
|
Loading…
Reference in a new issue