diff --git a/cs621/proj3/LoanApplication.java b/cs621/proj3/LoanApplication.java index 958b191..61f3383 100644 --- a/cs621/proj3/LoanApplication.java +++ b/cs621/proj3/LoanApplication.java @@ -8,6 +8,8 @@ public class LoanApplication public void run() { + PrintSpooler spooler = PrintSpooler.getSpooler(); + try { for (;;) @@ -26,6 +28,22 @@ public class LoanApplication System.out.print("Enter the principal balance: "); double principal = Double.parseDouble(br.readLine()); + + int type = 0; + while (type < 1 || type > 2) + { + System.out.println("Please select whether the loan is a simple interest loan or an amortized loan:"); + System.out.println("Select:"); + System.out.println(" 1) simple interest loan"); + System.out.println(" 2) amortized loan"); + type = Integer.parseInt(br.readLine()); + } + + Loan loan = (type == 1) + ? new SimpleLoan(name, rate, years, principal) + : new AmortizedLoan(name, rate, years, principal); + + spooler.printDocument(loan.process()); } } catch (Exception e) { } diff --git a/cs621/proj3/Makefile b/cs621/proj3/Makefile index eae6288..a9153ee 100644 --- a/cs621/proj3/Makefile +++ b/cs621/proj3/Makefile @@ -1,5 +1,5 @@ -all: *.class +all: $(patsubst %.java,%.class,$(wildcard *.java)) %.class: %.java javac $^