コード例 #1
0
        void ShowExpression(Notation notation)
        {
            Notation   ntn      = notation;
            Expression constExp = new ConstExp(double.Parse(ConstExpressionTextBox.Text));
            Expression monoExp  = GetMonoExpression(MonomialExpressionTextBox.Text);

            Expression binExp1 = GetMonoExpression(BinaryExpression1TextBox.Text);
            Expression binExp2 = GetMonoExpression(BinaryExpression2TextBox.Text);
            Expression binExp  = null;

            ListExpresstionTextBox.AppendText(constExp.toString(ntn) + "\n");
            ListExpresstionTextBox.AppendText(monoExp.toString(ntn) + "\n");

            string ope = OperatorTextBox.Text;

            switch (ope)
            {
            case "+":
                binExp = new AddExp(binExp1, binExp2);
                break;

            case "-":
                binExp = new MinusExp(binExp1, binExp2);
                break;

            case "*":
                binExp = new MulExp(binExp1, binExp2);
                break;

            case "/":
                binExp = new DivExp(binExp1, binExp2);
                break;
            }
            ListExpresstionTextBox.AppendText(binExp.toString(ntn) + "\n");
        }
コード例 #2
0
        private void DeriveButton_Click(object sender, EventArgs e)
        {
            ListExpresstionTextBox.Clear();

            Notation   ntn      = new InfixNotation();
            Expression constExp = new ConstExp(double.Parse(ConstExpressionTextBox.Text));
            Expression monoExp  = GetMonoExpression(MonomialExpressionTextBox.Text);

            Expression binExp1 = GetMonoExpression(BinaryExpression1TextBox.Text);
            Expression binExp2 = GetMonoExpression(BinaryExpression2TextBox.Text);
            Expression binExp  = null;

            constExp = constExp.Derive();
            monoExp  = monoExp.Derive();

            ListExpresstionTextBox.AppendText(constExp.toString(ntn) + "\n");
            ListExpresstionTextBox.AppendText(monoExp.toString(ntn) + "\n");


            string ope = OperatorTextBox.Text;

            switch (ope)
            {
            case "+":
                binExp = new AddExp(binExp1, binExp2).Derive();
                break;

            case "-":
                binExp = new MinusExp(binExp1, binExp2).Derive();
                break;

            case "*":
                binExp = new MulExp(binExp1, binExp2).Derive();
                break;

            case "/":
                binExp = new DivExp(binExp1, binExp2).Derive();
                break;
            }
            ListExpresstionTextBox.AppendText(binExp.toString(ntn) + "\n");
        }