第 3 課結束之後所完成之 MortgageCalculationService.egl 的程式碼

下列程式碼是第 3 課結束之後 MortgageCalculationService.egl 檔的文字。
package services;

service MortgageCalculationService

   function amortize(inputData MortgageCalculationResult inOut)
      amt MONEY = inputData.loanAmount;

      // convert to monthly rate
      rate DECIMAL(10, 8) = (1 + inputData.interestRate / 1200);

      // convert to months
      term INT = (inputData.term * 12);

      // calculate monthly payment amount
      pmt MONEY = (amt * (rate - 1) * Mathlib.pow(rate, term))
         / (MathLib.pow(rate, term) - 1);
      totalInterest MONEY = (pmt * term) - amt;

      // update result record
      inputData.monthlyPayment = pmt;
      inputData.interest = totalInterest;
   end
end

record MortgageCalculationResult

   // user input
   loanAmount MONEY;
   interestRate DECIMAL(10,8);
   term INT;

   // calculated fields
   monthlyPayment MONEY;
   interest MONEY;
end

意見