java:请帮个javaBean的忙,必加100分
来源:百度知道 编辑:UC知道 时间:2024/09/28 08:19:33
public class test{
private String first;
private String second;
private double result;
private String opertator;
public void setFirst(String first){
this.first=first;
}
public void setSecond(String second){
this.second=second;
}
public void setOperator(String operator){
this.operator=operator;
}
public String getFirst(){
return this.first;
}
public String getSecond(){
return this.second;
}
public String getOperator(){
return this.operator;
}
public double getResult(){
return this.result;
}
public void calculte(){
double one=Double.parseDouble(first);
double two=Double.parseDouble(second);
try{
if(operator.equals("+"))result=one+two;
else if(operator.equals("*"))result=one*two;
}catch(Exception e){
System.out.println(e);
}
<