一聚教程网:一个值得你收藏的教程网站

热门教程

设计的一个计算器类的源代码,很简陋哦,请各位高手不要见笑!

时间:2022-07-02 18:02:22 编辑:袖梨 来源:一聚教程网


//名字空间MyCalClass
//类名: CalClass
//无参的构造函数CalClass()
//6个用到的私有变量
//void PointClick()  按小数点
//string CE()  是计算器复位用的,clear函数
//string BackSpace(string Txt)  倒退键,参数是计算过程中现在显示的计算结果
//string NumClick(string Txt,int NumKey)  0-9数字键按下的响应,Txt是计算的当前结果,NumKey是按下的数字值
//string OpClick(string Txt,int OpKey) +,-,*,/,=几个键按下时的处理,Txt是计算的当前结果,OpKey是按下操作键的数字ID
namespace MyCalClass
{
    public class CalClass
    {
        private string ResultTxt;    //Get and Show The Result of the TextBox in application
        private bool PointIsDown;    //If the radix point was clicked;
        private double MidResult;    //To Store middle results
        private double Results;    //To store finally result
        private int LastClick;    //To sign last clicking button class,is number(1) or operator(2)
        private int LastOperator;    //To sign last clicked button of operator is who?0 is Null,1 is +,2 is - ,3 is *,4 is /,5 is =;
       public CalClass()
        {
            ResultTxt = "0.";
            PointIsDown = false;
            MidResult = 0;
            Results = 0;
            LastClick = 0;

热门栏目