示例#1
0
        /// <summary>
        /// 計算を実施する
        /// </summary>
        internal bool Calculate()
        {
            // 符号種別に応じた演算を行う
            switch (calcOperationType)
            {
            // 足し算の場合
            case ConstDefines.CalcType.Sum:
                calcResult += Convert.ToDouble(resultDispArea.Text);
                break;

            // 引き算の場合
            case ConstDefines.CalcType.Minus:
                calcResult -= Convert.ToDouble(resultDispArea.Text);
                break;

            // 掛け算の場合
            case ConstDefines.CalcType.Multiple:
                calcResult *= Convert.ToDouble(resultDispArea.Text);
                break;

            // 割り算の場合
            case ConstDefines.CalcType.Divide:
                if (Convert.ToDouble(resultDispArea.Text) == 0.0)
                {
                    resultDispArea.Text = "Zero Divide";
                    return(false);
                }
                calcResult /= Convert.ToDouble(resultDispArea.Text);
                break;

            // ここに来るのはあり得ない
            default:
                break;
            }

            // 計算結果を計算結果表示エリアに表示する
            resultDispArea.Text = calcResult.ToString();
            calcOperationType   = ConstDefines.CalcType.Undefined;
            return(true);
        }
示例#2
0
 /// <summary>
 /// 押されたボタンに対応する符号種別を取得する
 /// </summary>
 /// <param name="operation">変更後の符号</param>
 internal void SetCalcOperationFromText(string operation)
 {
     calcOperationType = ConstDefines.OperationTypeTable[operation];
 }