示例#1
0
 public void CalculateLoanGrades()
 {
     foreach (Loan loan in repo.Get())
     {
         LoanGrade grade = new LoanGrade(loan.LoanID);
         foreach (IExceptionRule rule in rules)
         {
             LoanException loanException = rule.CalculateLoanException(loan);
             if (loanException.Triggered)
             {
                 grade.AddException(loanException);
             }
         }
         grade.Recalculate();
         loan.Grade = grade;
         grades.Add(grade);
     }
 }
示例#2
0
 static void Main(string[] args)
 {
     if (args.Length != 2)
     {
         Console.WriteLine("provide the fully qualified input and output filenames as an arguments to the program...");
         return;
     }
     Console.WriteLine("Calculating Loan Grades...");
     rules      = RuleConfiguration.BuildRuleList();
     calculator = new LoanGradeCalculator(args[0], rules);
     calculator.CalculateLoanGrades();
     using (StreamWriter outputFile = new StreamWriter(args[1]))
     {
         outputFile.WriteLine(LoanGrade.Header());
         foreach (LoanGrade grade in calculator.grades)
         {
             outputFile.WriteLine(grade.ToString());
         }
     }
     Console.WriteLine("Done...");
 }