MSSwitch
This commit is contained in:
parent
15bf38744f
commit
37e271fd9e
3 changed files with 61 additions and 0 deletions
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)}");
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue