第1个回答 2017-11-20
public class InsuranceCheck { public Integer calacMoneyByBornYear(int bornYear) throws AgeException { int money = 1000; int years = this.year - bornYear; if (years - 16 < 0) { throw new AgeException("年龄太小,不用保险!"); } else if (years - 16 < 4) { money = 2000; } else if (years - 16 >= 4) { money = 1000; } return money; } public InsuranceCheck() {} public InsuranceCheck(int year) { this.year = year; } private int year = 2010;} //filename:AgeException.javapublic class AgeException extends Throwable { public AgeException() {} public AgeException(String message) { super(message); }}