Skip to content

Commit d2933a9

Browse files
committed
Added IUserActionManager and ConsoleInputManager, Added UserActionEnum
1 parent cf3425d commit d2933a9

5 files changed

Lines changed: 49 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
*/obj/*
22
*/bin/*
3-
.vs/*
3+
*/.vs/*

CellSimulator/CellSimulator.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
<Compile Include="Cell.cs" />
4646
<Compile Include="CellOverseer.cs" />
4747
<Compile Include="Enums\CellActionEnum.cs" />
48+
<Compile Include="Enums\UserActionEnum.cs" />
49+
<Compile Include="Input\ConsoleInputManager.cs" />
4850
<Compile Include="Interfaces\ICell.cs" />
4951
<Compile Include="Interfaces\IUserActionManager.cs" />
5052
<Compile Include="Interfaces\ICellPrinter.cs" />
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace CellSimulator.Enums
8+
{
9+
public enum UserActionEnum
10+
{
11+
INVALID,
12+
SAVE,
13+
LOAD,
14+
SWITCHSHOWINFO,
15+
}
16+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using CellSimulator.Enums;
7+
using CellSimulator.Interfaces;
8+
9+
namespace CellSimulator.Input
10+
{
11+
public class ConsoleInputManager : IUserActionManager
12+
{
13+
public UserActionEnum GetUserAction()
14+
{
15+
Console.Write("Enter Action: ");
16+
if (Enum.TryParse(Console.ReadLine().ToUpper(), out UserActionEnum result))
17+
{
18+
return result;
19+
}
20+
else
21+
{
22+
return UserActionEnum.INVALID;
23+
}
24+
25+
}
26+
}
27+
}

CellSimulator/Interfaces/IUserActionManager.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using CellSimulator.Enums;
67

78
namespace CellSimulator.Interfaces
89
{
9-
class IUserActionManager
10+
public interface IUserActionManager
1011
{
12+
UserActionEnum GetUserAction();
1113
}
1214
}

0 commit comments

Comments
 (0)