C# Calculator Class

前端 未结 4 903
太阳男子
太阳男子 2021-01-17 00:36

I was given this homework assignment, which I have been having a hard time with. The form was written and we had to write the class. Currently when I run the program my equa

4条回答
  •  既然无缘
    2021-01-17 01:15

    In the main code, you have called the Equal() method like this:

    if (newValue)
        calc.Equals();
    else
        calc.Equals(displayValue); //Your class do not have this.
    

    So, you should do this first

    //I am not sure why you need to pass in the displayValue parameter, so I presume it would not return anything.
    public void Equal(Decimal displayValue)
    {
            //Do the things you suppose to do
    }
    

    And for your 9 + 9 = 9 problem, it is simply because in your code, you only press your click event Add_Button for once. Make a break point at your Add() method. Then try to do like this:

    9 --> press your Add_Button --> 9 --> press your Add_Button --> check your currentValue

提交回复
热议问题