public void DoSupport(Trouble trouble) { if (Resolve(trouble)) { Done(trouble); } else if (next != null) { next.DoSupport(trouble); } else { Fail(trouble); } }
public void SupportTrouble(Trouble trouble) { if (Resolve(trouble)) { Console.WriteLine("問題" + trouble.Number + "は" + _name + "が解決しました。"); } else if (_next != null) { _next.SupportTrouble(trouble); } else { Console.WriteLine("問題" + trouble.Number + "は現在のサポート体制では解決できませんでした。"); } }
override public bool Resolve(Trouble trouble) { return(false); }
public override bool Resolve(Trouble trouble) { return(trouble.Number == number); }
public override bool Resolve(Trouble trouble) { return(trouble.Number % 2 == 1); }
public override bool Resolve(Trouble trouble) { return(trouble.Number < limit); }
protected void Fail(Trouble trouble) { Console.WriteLine(trouble + " cannot be resolved."); }
protected void Done(Trouble trouble) { Console.WriteLine(trouble + " is resolved by " + this + "."); }
protected abstract bool Resolve(Trouble trouble);
abstract public bool Resolve(Trouble trouble);