public void Run(Statement statement) { var processor = Processors.GetProcessor(statement); if (processor is IMemoryProcessor) { ((IMemoryProcessor)processor).Process(Memory); } if (processor is IOutputProcessor) { ((IOutputProcessor)processor).Process(Memory, Output); } if (processor is IInputProcessor) { ((IInputProcessor)processor).Process(Memory, Input); } }
static void Main(string[] args) { Processors processors = new Processors(); Memory memory = new Memory(); IOutput output = new MemoryOutput(); IInput input = new MemoryInput("ABCD"); Machine machine = new Machine() { Memory = memory, Processors = processors, Output = output, Input = input }; machine.Run(new Tape(",.,.,.,.")); Console.WriteLine("\n\nDone."); }