Ejemplo n.º 1
0
        T SetupVisitor <T>(CalculationPartList toOutputTo) where T : CalculationVisitor, new()
        {
            var visitor = new T();

            visitor.OutputTo(toOutputTo);
            return(visitor);
        }
Ejemplo n.º 2
0
        public CalculationPartList Visit <T>() where T : CalculationVisitor, new()
        {
            var toOutputTo = new CalculationPartList();
            var visitor    = SetupVisitor <T>(toOutputTo);

            ForEach(visitor.ProcessCharacter);

            return(toOutputTo);
        }
Ejemplo n.º 3
0
        public void Calculate()
        {
            CalculationPartList parts = Sequence.GetParts();

            parts = parts.Visit <WholeNumericCalculationVisitor>();
            parts = parts.Visit <FractionalNumericCalculationVisitor>();
            parts = parts.Visit <DivideCalculationVisitor>();
            parts = parts.Visit <MultiplyCalculationVisitor>();
            parts = parts.Visit <AddCalculationVisitor>();
            parts = parts.Visit <SubtractCalculationVisitor>();

            Sequence.Clear();
            Sequence.AddPart(parts.Single());

            OutputSequence();
        }
 public void OutputTo(CalculationPartList toOutputTo)
 {
     output = toOutputTo;
 }