Codice terminato per MortgageCalculationService.egl dopo la Lezione 3

Il codice riportato di seguito è il testo del file MortgageCalculationService.egl al termine della Lezione 3.
package services;

service MortgageCalculationService

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

      		// converte in tasso mensile
      		rate DECIMAL(10, 8) = (1 + inputData.interestRate / 1200);

      		// converte in mesi
      		term INT = (inputData.term * 12);

      		// calcola l'importo del pagamento mensile
      pmt MONEY = (amt * (rate - 1) * Mathlib.pow(rate, term)) 
         / (MathLib.pow(rate, term) - 1);
      totalInterest MONEY = (pmt * term) - amt;

      		// aggiorna il record dei risultati
      inputData.monthlyPayment = pmt;
      		inputData.interest = totalInterest;
   end
end

record MortgageCalculationResult

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

   	// campi calcolati
   	monthlyPayment MONEY;
   	interest MONEY;
end

Feedback