package Hypotheek; import java.util.List; import Sequenic.T2.* ; public class Hypotheek_TI { private Hypotheek SUT ; private static int getdata(int[] a, int x) { return a[x % a.length] ; } private static int[] age_data = {-1,0,1, 15,16,17,18, 19,20,21, 29,30,31, 39,40,41, 55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70, Hypotheek.MAX_AGE-1, Hypotheek.MAX_AGE, Hypotheek.MAX_AGE+1} ; static class Age { int age ; public Age(int x) { age = getdata(age_data,x) ; } } private static int[] housePriceIncrRate_data = {-1,0,1, 100,101,200,201, 3000,3010,9999 } ; static class HousePriceIncrRate { int housePriceIncrRate ; public HousePriceIncrRate(int x) { housePriceIncrRate = getdata(housePriceIncrRate_data,x) ; } } private static int[] duration_data = {-1,0,1, 7,15,30,29,43,51, Hypotheek.MAX_LOAN_DURATION-1, Hypotheek.MAX_LOAN_DURATION, Hypotheek.MAX_LOAN_DURATION+1 } ; static class Duration { int duration ; public Duration(int x) { duration = getdata(duration_data,x) ; } } private static int[] loan_data = { -1,0,1, 111, 1111, 22222, 333333, 20000000, 900000000, Hypotheek.MAX_LOAN-1, Hypotheek.MAX_LOAN , Hypotheek.MAX_LOAN+1 } ; static class Loan { int loan ; public Loan(int x) { loan = getdata(loan_data,x) ; } } private static int[] monthlyPayment_data = {-1,0,1, 12, 123, 4567, 50000, 890100, 1000000, 10000000, Hypotheek.MAX_LOAN, } ; static class MonthlyPayment { int monthlyPayment ; public MonthlyPayment(int x) { monthlyPayment = getdata(monthlyPayment_data,x) ; } } private static int[] income_data = { -1, 0, 1, new InkomenBelasting2009().schijf1_max - 10000, new InkomenBelasting2009().schijf2_max - 10000, new InkomenBelasting2009().schijf3_max - 100000, new InkomenBelasting2009().schijf3_max + 100000 } ; static class Income { int income ; public Income(int x) { income = getdata(income_data,x) ; } } public static class MyBaseDomain extends Sequenic.T2.BaseDomainSmall { // We need a public and no-arg constructor: public MyBaseDomain() { super() ; } public Object[] get(Class C) { if (C == Integer.TYPE) { Object[] result = new Integer[1] ; result[0] = new Integer(rnd.nextInt(100)) ; return result ; } return super.get(C) ; } } private static final int[] interest_data = { -1, 0, 9, 300, 555, 3456 } ; static public class Interest { int interest ; public Interest(int x) { interest = getdata(interest_data,x) ; } } private static final int[] percentageToSave_data = { -1, 0, 10, 900, 5678 } ; static public class PercentageToSave { int percentageToSave ; public PercentageToSave(int x) { percentageToSave = getdata(percentageToSave_data,x) ; } } static public class PurchaseCostPercentage { int purchaseCostPercentage ; public PurchaseCostPercentage(int x) { purchaseCostPercentage = getdata(percentageToSave_data,x) ; } } public Hypotheek_TI(Age age, Loan loan, MonthlyPayment monthlyPayment, Duration duration , HousePriceIncrRate housePriceIncrRate, Income income, Interest interest, PercentageToSave percentageToSave, PurchaseCostPercentage purchaseCostPercentage) { SUT = new Hypotheek() ; SUT.age = age.age ; SUT.duration = duration.duration ; SUT.loan = loan.loan ; SUT.monthlyPayment = monthlyPayment.monthlyPayment ; SUT.assumedHousePriceIncrRate = housePriceIncrRate.housePriceIncrRate ; SUT.income = income.income ; SUT.interestRate = interest.interest ; SUT.percentageToSave = percentageToSave.percentageToSave ; SUT.purchaseCostPercentage = purchaseCostPercentage.purchaseCostPercentage ; } public Hypotheek.Result calculate() { assert SUT.loan >= 0 : "PRE" ; Hypotheek.Result R = SUT.calculate() ; if (R!=null) { assert R.remaining >= 0 ; assert R.totPaidBruto <= SUT.loan ; } return R ; } public List calcYearlyCummulativeProgressOfLoanPaid() { Hypotheek.Result R = SUT.calculate() ; assert R != null : "PRE" ; return SUT.calcYearlyCummulativeProgressOfLoanPaid(R) ; } public List calcYearlyCummulativeProgressOfSaving() { Hypotheek.Result R = SUT.calculate() ; assert R != null : "PRE" ; return SUT.calcYearlyCummulativeProgressOfSaving(R) ; } public List calcYearlyCummulativeProgressOfTaxReduction() { Hypotheek.Result R = SUT.calculate() ; assert R != null : "PRE" ; return SUT.calcYearlyCummulativeProgressOfTaxReduction(R) ; } }