diff --git a/mortgage-pre-approved-list/CreditUnion.java b/mortgage-pre-approved-list/CreditUnion.java index c373478..ee01181 100644 --- a/mortgage-pre-approved-list/CreditUnion.java +++ b/mortgage-pre-approved-list/CreditUnion.java @@ -1,7 +1,7 @@ +import java.util.Scanner; import java.util.ArrayList; public class CreditUnion{ - //ArrayList of HomeBuyer objects as borrower roster ArrayList homeBuyers = new ArrayList(); public ArrayList getPreApprovedList(){ @@ -16,4 +16,30 @@ public class CreditUnion{ return approvedHomeBuyerList; } + public void addHomeBuyer(HomeBuyer buyer){ + homeBuyers.add(buyer); + } + + public void inputBuyer(Scanner scnr){ + HomeBuyer currBuyer; + int quitFlag = 0; + + String fName; + String lName; + int creditRating; + + while (true){ + System.out.print("Type a negative #; positive to continue: "); + quitFlag = scnr.nextInt(); + if (quitFlag < 0){break;} + + System.out.print("Type first name last name credit rating: "); + fName = scnr.next(); + lName = scnr.next(); + creditRating = scnr.nextInt(); + + currBuyer = new HomeBuyer(fName, lName, creditRating); + addHomeBuyer(currBuyer); + } + } } diff --git a/mortgage-pre-approved-list/HomeBuyer.java b/mortgage-pre-approved-list/HomeBuyer.java index 0a506b3..4a65a05 100644 --- a/mortgage-pre-approved-list/HomeBuyer.java +++ b/mortgage-pre-approved-list/HomeBuyer.java @@ -20,5 +20,8 @@ public class HomeBuyer{ public int getCreditScore(){ return creditScore; } + public String toString(){ + return fName + " " + lName + " (Credit Score: " + creditScore + ")"; + } } diff --git a/mortgage-pre-approved-list/LabProgram.java b/mortgage-pre-approved-list/LabProgram.java index e69de29..e145239 100644 --- a/mortgage-pre-approved-list/LabProgram.java +++ b/mortgage-pre-approved-list/LabProgram.java @@ -0,0 +1,27 @@ +import java.util.Scanner; +import java.util.ArrayList; +public class LabProgram{ + + public static void main(String[] args) { + Scanner scnr = new Scanner(System.in); + + CreditUnion cu = new CreditUnion(); + + String fName; + String lName; + int creditRating; + + ArrayList preApprovedBuyers; + + cu.inputBuyer(scnr); + + System.out.println("Mortgage Pre-Approved's list:"); + + preApprovedBuyers = cu.getPreApprovedList(); + + for (HomeBuyer buyer:preApprovedBuyers){ + System.out.println(buyer.toString()); + } + + } +}