﻿using MortgageCalc.Models;
using System;
using System.Collections.Generic;

namespace MortgageCalc.Calculators
{
    public class InterestOnlyScheduleBuilder
    {
        private RateCalc _calc = new RateCalc(6); // initialize with 6 decimal places
        private decimal _monthlyPayment;
        private decimal _principal;
        private decimal _rate;
        private int _term;

        public InterestOnlyScheduleBuilder(decimal principal, decimal rate, int term)
        {
            this._principal = principal;
            this._rate = rate;
            this._term = term;

            this._monthlyPayment = this._calc.Interest(principal, rate);
        }

        public Schedule Schedule()
        {
            return new Schedule
            {
                MonthlyPayment = Math.Round(this._monthlyPayment, 2),
                CostOfCredit = Math.Round(this._monthlyPayment * this._term, 2)
            };
        }
    }
}
