java代码写亲戚计算器 java的计算器代码( 六 )


isChoiseOptType=false;
} else if (e.getSource().equals(b9)) {
this.temp.append(b9.getLabel());
this.textField.setText(this.temp.toString());
isChoiseOptType=false;
} else if (e.getSource().equals(bp)) {
if(this.temp.length()=0)
this.temp.append("0");
this.temp.append(bp.getLabel());
this.textField.setText(this.temp.toString());
isChoiseOptType=false;
} else if (e.getSource().equals(ba)) {
if(!isChoiseOptType){
value=https://www.04ip.com/post/this.textField.getText();
if(value.lastIndexOf(".")==value.length()-1){
value=https://www.04ip.com/post/value.substring(0,value.length()-1);
}
this.optValue=https://www.04ip.com/post/value;
this.temp=new StringBuffer("");
}
this.optType=ba.getLabel();
isChoiseOptType=true;
} else if (e.getSource().equals(bs)) {
if(!isChoiseOptType){
value=https://www.04ip.com/post/this.textField.getText();
if(value.lastIndexOf(".")==value.length()-1){
value=https://www.04ip.com/post/value.substring(0,value.length()-1);
}
this.optValue=https://www.04ip.com/post/value;
this.temp=new StringBuffer("");
}
this.optType=bs.getLabel();
isChoiseOptType=true;
} else if (e.getSource().equals(bm)) {
if(!isChoiseOptType){
value=https://www.04ip.com/post/this.textField.getText();
if(value.lastIndexOf(".")==value.length()-1){
value=https://www.04ip.com/post/value.substring(0,value.length()-1);
}
this.optValue=https://www.04ip.com/post/value;
this.temp=new StringBuffer("");
}
this.optType=bm.getLabel();
isChoiseOptType=true;
} else if (e.getSource().equals(bd)) {
if(!isChoiseOptType){
value=https://www.04ip.com/post/this.textField.getText();
if(value.lastIndexOf(".")==value.length()-1){
value=https://www.04ip.com/post/value.substring(0,value.length()-1);
}
this.optValue=https://www.04ip.com/post/value;
this.temp=new StringBuffer("");
}
this.optType=bd.getLabel();
isChoiseOptType=true;
}else if (e.getSource().equals(be)) {
if(!this.optType.equals("")){
BigDecimal opt1=new BigDecimal(this.optValue);
value=https://www.04ip.com/post/this.textField.getText();
if(value.lastIndexOf(".")==value.length()-1){
value=https://www.04ip.com/post/value.substring(0,value.length()-1);
}
BigDecimal opt2=new BigDecimal(value);
BigDecimal result=new BigDecimal(0);
if(this.optType.equals("+")){
result=opt1.add(opt2);
}else if(this.optType.equals("-")){
result=opt1.subtract(opt2);
}else if(this.optType.equals("*")){
result=opt1.multiply(opt2);
}else if(this.optType.equals("/")){
result=opt1.divide(opt2);
}else if(this.optType.equals("%")){
result=opt1.remainder(opt2);
}
this.textField.setText(result.toString());
this.temp=new StringBuffer("");
isChoiseOptType=false;
this.optValue="https://www.04ip.com/post/0";
}
} else if (e.getSource().equals(bc)) {
this.temp=new StringBuffer();
this.textField.setText("0");
} else if (e.getSource().equals(bt)) {
value=https://www.04ip.com/post/this.textField.getText();
value=https://www.04ip.com/post/value.substring(0,value.length()-1);
if(value.indexOf("-")=0value.length()=1){
value="https://www.04ip.com/post/0";
this.temp=new StringBuffer("");
}else{
this.temp=new StringBuffer(value);
}
this.textField.setText(value);
}else if (e.getSource().equals(bh)) {
value=https://www.04ip.com/post/this.textField.getText();
if(value.indexOf("-")==0){
value=https://www.04ip.com/post/value.substring(1,value.length());
}else{
value="https://www.04ip.com/post/-"+value;
}
this.temp=new StringBuffer(value);
this.textField.setText(value);

推荐阅读