java:请帮个javaBean的忙,必加100分

来源:百度知道 编辑:UC知道 时间:2024/09/28 08:19:33
学了一些java的基础知识,但是对javaBean不了解,请帮我写个:求任意两个整数的和,与求这两个整数的积的java组件,若能加一些注释说明,那更好.并用其它函数实现调用这个组件实现求和与求积的功能.谢谢.

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);
}
<