示例#1
0
 // トラブル解決の手順
 public void DoSupport(Trouble trouble)
 {
     if (Resolve(trouble))
     {
         Done(trouble);
     }
     else if (next != null)
     {
         next.DoSupport(trouble);
     }
     else
     {
         Fail(trouble);
     }
 }
示例#2
0
 // 未解決
 protected virtual void Fail(Trouble trouble)
 {
     Console.WriteLine(trouble + " cannot be resolved.");
 }
示例#3
0
 // 解決
 protected virtual void Done(Trouble trouble)
 {
     Console.WriteLine(trouble + " is resolved by " + this + ".");
 }
示例#4
0
 // 解決用メソッド
 protected abstract bool Resolve(Trouble trouble);
示例#5
0
 // 解決用メソッド
 protected override bool Resolve(Trouble trouble)
 {
     return(trouble.Number == number);
 }
示例#6
0
 // 解決用メソッド
 protected override bool Resolve(Trouble trouble)
 {
     return(trouble.Number < limit);
 }
示例#7
0
 // 解決用メソッド
 protected override bool Resolve(Trouble trouble)
 {
     return(false); // 自分は何も処理しない
 }