日期:2014-05-20  浏览次数:20703 次

各位高手,救急~帮帮我吧!拜托~
这是用JAVA编写的计算器中的一段程序,麻烦各位高手帮帮我,下面这段程序是什么功能?拜托~
程序如下:
if(this.keyAvailable && e.getActionCommand().length()==1 && e.getActionCommand().compareTo("0")>=0 && e.getActionCommand().compareTo("9")<=0)
{
if(this.isTempNowInput)
{
this.dNowInput=0;
this.isTempNowInput=false;
}
this.nBitsNum++;
if(this.alreadyHaveDot==false)
this.dNowInput=this.dNowInput*10+Double.parseDouble(e.getActionCommand());
else
{
double temp=Double.parseDouble(e.getActionCommand());
for(int i=this.n;i<0;i++)
{
temp*=0.1;
}
this.dNowInput+=temp;
this.n--;
}
this.tf1.setText(Double.toString(this.dNowInput));
}
// key dot
if(this.keyAvailable && e.getActionCommand()==".")
{
if(this.alreadyHaveDot==false)
{
this.nBitsNum++;
this.alreadyHaveDot=true;
this.n=-1;
}
}
//key "+","-","*","/"
if(this.keyAvailable && e.getActionCommand()=="+" || e.getActionCommand()=="-" || e.getActionCommand()=="*" || e.getActionCommand()=="/")
{
if(this.alreadyClickedEqueal)
{
this.dNowInput=this.dResult;
this.isTempNowInput=true;
}
else
{
switch(this.nOperation)
{
case 1: this.dResult+=this.dNowInput; break;
case 2: this.dResult-=this.dNowInput; break;
case 3: this.dResult*=this.dNowInput; break;
case 4:
{
if(this.dNowInput==0)
{
tf1.setText("除数不能为零");
this.keyAvailable=false;
}
else this.dResult=this.dResult/this.dNowInput;
}
}
if(this.keyAvailable)tf1.setText(Double.toString(this.dResult));
this.dNowInput=0;
}
if(e.getActionCommand()=="+")
{
this.nOperation=1;
}
if(e.getActionCommand()=="-")
{
this.nOperation=2;
}
if(e.getActionCommand()=="*")
{
this.nOperation=3;
}
if(e.getActionCommand()=="/")
{
this.nOperation=4;
}
this.nBitsNum=0;
this.alreadyClickedEqueal=false;
}
// key "+/-"
if(this.keyAvailable && e.getActionCommand()=="+/-")
{
this.dNowInput=0-this.dNowInput;
tf1.setText(Double.toString(this.dNowInput));
}
// key "C"
if(e.getActionCommand()=="C")
{
this.nBitsNum=0;
this.dResult=0;
this.dNowInput=0;
this.alreadyHaveDot=false;
this.n=0;
this.nOperation=1;
this.keyAvailable=true;
this.alreadyClickedEqueal=false;
tf1.setText("0.");
}
// key "CE"
if(e.getActionCommand()=="CE")
{
this.nBitsNum=0;
this.dNowInput=0;
this.alreadyHaveDot=false;
this.n=0;
this.nOperation=1;
this.keyAvailable=true;
tf1.setText("0.");
}

// key "sqrt"
if(this.keyAvailable && e.getActionCommand()=="sqrt")
{
if(this.alreadyClickedEqueal)
{
if(this.dResult>=0)
{
this.dResult=Math.sqrt(this.dResult);
tf1.setText(Double.toString(this.dResult));
}
else
{
tf1.setText("函数输入无效");
this.keyAvailable=false;
}
}
else
{
if(this.dNowInput>=0)
{
this.dNowInput=Math.sqrt(this.dNowInput);
tf1.setText(Double.toString(this.dNowInput));
}
else