forked from EdisonTalk/DesignPattern.Samples.CSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActionNode.cs
38 lines (35 loc) · 915 Bytes
/
ActionNode.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EDC.DesignPattern.Interpreter
{
/// <summary>
/// 终结符表达式:动作解释
/// </summary>
public class ActionNode : AbstractNode
{
private string action;
public ActionNode(string action)
{
this.action = action;
}
// 动作(移动方式)表达式的解释操作
public override string Interpret()
{
if (action.Equals("move", StringComparison.OrdinalIgnoreCase))
{
return "移动";
}
else if (action.Equals("run", StringComparison.OrdinalIgnoreCase))
{
return "快速移动";
}
else
{
return "无效指令";
}
}
}
}