public Double check(Date birthday) throws AgeException{ if(birthday==null){ throw new AgeException("生日为空"); } int year = birthday.getYear(); int temYear=2010-year; if(temYear<16){ throw new AgeException("年龄太小,不用保险"); }else if((temYear-16)<4){ return 2000.0d; }else{ return 1000.0d; } }
}
public class AgeException extends Exception{
/** * */ private static final long serialVersionUID = 164570123780291206L;
public AgeException(String string) { super(string); }