M
mark jason
hi,
In my program I need to return a result object as below
class MyResult {
private boolean success;
private double distance;
private String matchFileName;
private String message;
public MyResult (boolean s, double d, String mfn, String msg) {
this.success = s;
this.distance = d;
this.matchFileName = mfn;
this.message = msg;
}
//getters and setters...
}
In my program , I am returning a MyResult instance containing values
from a calculation.If an exception occurs ,I would like to return the
object with values which represent a failed calculation .The problem
is that,I cannot put distance as 0.0 since it is one of the valid
distance values.
So I put distance as Double.NaN.I don't know if this is the correct
way..Can someone suggest a better solution?
public MyResult getResult() {
MyResult res = null;
try{
res = calculate();
}catch(SomeException e) {
return new MyResult ( false, Double.NaN, "", e.getMessage() );
}
return res;
}
regards,
mark
In my program I need to return a result object as below
class MyResult {
private boolean success;
private double distance;
private String matchFileName;
private String message;
public MyResult (boolean s, double d, String mfn, String msg) {
this.success = s;
this.distance = d;
this.matchFileName = mfn;
this.message = msg;
}
//getters and setters...
}
In my program , I am returning a MyResult instance containing values
from a calculation.If an exception occurs ,I would like to return the
object with values which represent a failed calculation .The problem
is that,I cannot put distance as 0.0 since it is one of the valid
distance values.
So I put distance as Double.NaN.I don't know if this is the correct
way..Can someone suggest a better solution?
public MyResult getResult() {
MyResult res = null;
try{
res = calculate();
}catch(SomeException e) {
return new MyResult ( false, Double.NaN, "", e.getMessage() );
}
return res;
}
regards,
mark