-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCommand.cs
More file actions
55 lines (53 loc) · 1.72 KB
/
Command.cs
File metadata and controls
55 lines (53 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CodePainterApp
{
class Command
{
public CommandType CommandType = CommandType.UNKNOWN;
string Parameter = string.Empty;
internal void Resolve(string commandName , string parameter = "")
{
switch(commandName)
{
case "GO":
this.CommandType = CommandType.GO;
this.Parameter = parameter;
break;
case "TURN":
this.CommandType = CommandType.TURN;
this.Parameter = parameter;
break;
case "COLOR":
this.CommandType = CommandType.COLOR;
this.Parameter = parameter;
break;
case "DONTPAINT":
this.CommandType = CommandType.DONTPAINT;
break;
case "PAINT":
this.CommandType = CommandType.PAINT;
break;
case "REPEAT":
this.CommandType = CommandType.REPEAT;
this.Parameter = parameter;
break;
case "ENDREPEAT":
this.CommandType = CommandType.ENDREPEAT;
break;
}
}
internal int GetParameterAsInteger()
{
int paramValue = 0;
int.TryParse(Parameter, out paramValue);
return paramValue;
}
internal string GetParameter()
{
return Parameter;
}
}
}