public Factorial(int i) //throws Exception { trace = new Trace("fact_trace"); _fact = new FactorialType(i); EqualsOneRange defaultRange = new EqualsOneRange(); GreaterThanOneRange multRange = new GreaterThanOneRange(); LessThanOneRange fRange = new LessThanOneRange(); EqualsTwoRange desiredRange = new EqualsTwoRange(); _multiply = new MultiplyAction(_fact); _initialize = new InitializeAction(_fact); _multiply.SetTrace(trace); _initialize.SetTrace(trace); _multiply.SetId("multiply"); _initialize.SetId("initialize"); _mult = new State(_multiply, true); _def = new State(_initialize); _mult.SetId("mult"); _def.SetId("default"); _forbidden = new ForbiddenState(); _desired = new DesiredState(); _forbidden.SetId("f1"); _desired.SetId("d1"); _mult.SetTrace(trace); _def.SetTrace(trace); _forbidden.SetTrace(trace); _desired.SetTrace(trace); _fact.AddRange(_mult, multRange); _fact.AddRange(_def, defaultRange); _fact.AddRange(_forbidden, fRange); _fact.AddRange(_desired, desiredRange); _behavior = new FactorialBehavior(_fact); _behavior.Add(_mult); _behavior.Add(_def); this.Add(_behavior); Element.SetWarnOnErrroneousAction(true); State s = _fact.CurrentState(); if (HasTrace()) { _trace.AddTrace(s); } }
public Factorial(FactorialBehavior behavior) : base() { this.Add(behavior); }