Пример #1
0
        /// <summary>
        /// Creates selected command instance
        /// </summary>
        /// <param name="operation">Operation type</param>
        /// <param name="mathUnit">Math unit</param>
        /// <returns>Command instance</returns>
        public static Command Create(string operation, MathUnit mathUnit)
        {
            Command command = null;

            switch (operation)
            {
            case "+":
                command = new AdditionCommand(mathUnit);
                break;

            case "-":
                command = new SubtractCommand(mathUnit);
                break;

            case "*":
                command = new MultiplicationCommand(mathUnit);
                break;

            case "/":
                command = new DivisionCommand(mathUnit);
                break;

            case "pow":
                command = new PowCommand(mathUnit);
                break;

            case "extract":
                command = new ExtractCommand(mathUnit);
                break;

            case "round":
                command = new RoundCommand(mathUnit);
                break;

            case "exp":
                command = new ExpCommand(mathUnit);
                break;

            case "log":
                command = new LogCommand(mathUnit);
                break;
            }
            return(command);
        }
Пример #2
0
        public Emulator(GraphicsBackend graphics, AudioBackend audio, InputBackend input)
        {
            GraphicsBackend = graphics;
            AudioBackend    = audio;
            InputBackend    = input;

            graphics.Emulator = this;
            audio.Emulator    = this;
            input.Emulator    = this;

            units.Add(Memory          = new MemoryUnit(this));
            units.Add(Graphics        = new GraphicsUnit(this));
            units.Add(Audio           = new AudioUnit(this));
            units.Add(Math            = new MathUnit(this));
            units.Add(Input           = new InputUnit(this));
            units.Add(CartridgeLoader = new CartridgeUnit(this));

            foreach (var unit in units)
            {
                unit.Init();
            }
        }
Пример #3
0
 /// <summary>
 /// Executes command
 /// </summary>
 public override void Execute()
 {
     initialValue = MathUnit.Result;
     MathUnit.RunBinary("/", ParameterValue);
 }
Пример #4
0
 /// <summary>
 /// Creates instance of the DivisionCommand class
 /// </summary>
 /// <param name="mathUnit">Math unit</param>
 public DivisionCommand(MathUnit mathUnit)
 {
     this.MathUnit = mathUnit;
 }
Пример #5
0
 /// <summary>
 /// Executes command
 /// </summary>
 public override void Execute()
 {
     initialValue = MathUnit.Result;
     MathUnit.RunUnary("exp");
 }
Пример #6
0
 /// <summary>
 /// Creates instance of the ExpCommand class
 /// </summary>
 /// <param name="mathUnit">Math unit</param>
 public ExpCommand(MathUnit mathUnit)
 {
     this.MathUnit = mathUnit;
 }
Пример #7
0
 /// <summary>
 /// Creates instance of the MultiplicationCommand class
 /// </summary>
 /// <param name="mathUnit">Math unit</param>
 public MultiplicationCommand(MathUnit mathUnit)
 {
     this.MathUnit = mathUnit;
 }
Пример #8
0
 /// <summary>
 /// Creates instance of the LogCommand class
 /// </summary>
 /// <param name="mathUnit">Math unit</param>
 public LogCommand(MathUnit mathUnit)
 {
     this.MathUnit = mathUnit;
 }
Пример #9
0
 /// <summary>
 /// Creates instance of the AdditionCommand class
 /// </summary>
 /// <param name="mathUnit">Math unit</param>
 public AdditionCommand(MathUnit mathUnit)
 {
     this.MathUnit = mathUnit;
 }
Пример #10
0
 /// <summary>
 /// Creates instance of the ExtractCommand class
 /// </summary>
 /// <param name="mathUnit">Math unit</param>
 public ExtractCommand(MathUnit mathUnit)
 {
     this.MathUnit = mathUnit;
 }
Пример #11
0
 /// <summary>
 /// Creates instance of the PowCommand class
 /// </summary>
 /// <param name="mathUnit">Math unit</param>
 public PowCommand(MathUnit mathUnit)
 {
     this.MathUnit = mathUnit;
 }
Пример #12
0
 /// <summary>
 /// Creates instance of the RoundCommand class
 /// </summary>
 /// <param name="mathUnit">Math unit</param>
 public RoundCommand(MathUnit mathUnit)
 {
     this.MathUnit = mathUnit;
 }