From 3d150044193982fabe2898e3108c142eb25f02bc Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sat, 10 Oct 2020 21:42:10 -0400 Subject: [PATCH 01/26] add constructors --- .gitattributes | 1 + .gitignore | 4 + feedback.txt | 8 +- pom.xml | 14 +- .../CodingCompCsvUtil.java | 27 +- .../structures/Agent.java | 148 ++++++- .../structures/Claim.java | 122 +++++- .../structures/Customer.java | 388 ++++++++++++++++++ .../structures/Dependent.java | 70 ++++ .../structures/Vendor.java | 122 +++++- 10 files changed, 893 insertions(+), 11 deletions(-) create mode 100644 .gitattributes create mode 100644 .gitignore diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..92be83e --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text eol=crlf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..656e203 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.idea +.idea/**/* + +*.iml \ No newline at end of file diff --git a/feedback.txt b/feedback.txt index b931d50..eda5ea6 100644 --- a/feedback.txt +++ b/feedback.txt @@ -1,9 +1,11 @@ -Your team (name of each individual participating): +Your team (name of each individual participating): Mudit Gupta, Manoj Niverthi How many JUnits were you able to get to pass? Document and describe any enhancements included to help the judges properly grade your submission. - Step 1: - Step 2: + Step 1: We used Checkstyle to make sure the code was readable according to publicly agreed upon standards. + Step 2: We made all fileIO related methods and tests throw IOException to account for when a file is not found. + If a file is not found, is does not make sense to just return an empty list, as we should instead tell the user that they are attempting to read a non-present file. + We also changed some of the tests to throw the IOException. Feedback for the coding competition? Things you would like to see in future events? diff --git a/pom.xml b/pom.xml index 21d55bf..c35e2ff 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,19 @@ 4.0.0 coding-competition 1.0.0-SNAPSHOT - jar + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + + jar sf.codingcompetition2020 coding-competition diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 58267da..50a3ad6 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -10,6 +10,14 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.MappingIterator; import com.fasterxml.jackson.databind.ObjectReader; @@ -29,8 +37,21 @@ public class CodingCompCsvUtil { * @param classType -- Class of entries being read in. * @return -- List of entries being returned. */ - public List readCsvFile(String filePath, Class classType) { - + public List readCsvFile(String filePath, Class classType) throws IOException { + File file = new File(filePath); + FileReader fr = new FileReader(file); + BufferedReader br = new BufferedReader(fr); + String entry; + List interpretedFile = new ArrayList<>(); + while ((entry = br.readLine()) != null) { + List interpretedLine = Arrays.asList(entry.split("\\s*,\\s*")); + try { + interpretedFile.add(classType.getConstructor(List.class).newInstance()); + } catch (NoSuchMethodException nsme) { + nsme.printStackTrace(); + } + } + return interpretedFile; } @@ -40,7 +61,7 @@ public List readCsvFile(String filePath, Class classType) { * @param area -- The area from which the agents should be counted. * @return -- The number of agents in a given area */ - public int getAgentCountInArea(String filePath,String area) { + public int getAgentCountInArea(String filePath, String area) { } diff --git a/src/main/java/sf/codingcompetition2020/structures/Agent.java b/src/main/java/sf/codingcompetition2020/structures/Agent.java index e2e6f93..43dd53a 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Agent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Agent.java @@ -1,11 +1,155 @@ package sf.codingcompetition2020.structures; public class Agent { - + private int agentId; private String area; private String language; private String firstName; private String lastName; - + + /** + * Default Agent constructor + */ + private Agent(int agentId, String area, String language, String firstName, String lastName) { + this.agentId = agentId; + this.area = area; + this.language = language; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Builder constructor + * @param builder + */ + public Agent(Builder builder) { + this( + builder.agentId, + builder.area, + builder.language, + builder.firstName, + builder.lastName); + } + + /** + * Returns value of agentId + * @return + */ + public int getAgentId() { + return agentId; + } + + /** + * Sets new value of agentId + * @param + */ + public void setAgentId(int agentId) { + this.agentId = agentId; + } + + /** + * Returns value of area + * @return + */ + public String getArea() { + return area; + } + + /** + * Sets new value of area + * @param + */ + public void setArea(String area) { + this.area = area; + } + + /** + * Returns value of language + * @return + */ + public String getLanguage() { + return language; + } + + /** + * Sets new value of language + * @param + */ + public void setLanguage(String language) { + this.language = language; + } + + /** + * Returns value of firstName + * @return + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets new value of firstName + * @param + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * Returns value of lastName + * @return + */ + public String getLastName() { + return lastName; + } + + /** + * Sets new value of lastName + * @param + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public static class Builder { + private int agentId; + private String area; + private String language; + private String firstName; + private String lastName; + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder agentId(int agentId) { + this.agentId = agentId; + return this; + } + + public Builder area(String area) { + this.area = area; + return this; + } + + public Builder language(String language) { + this.language = language; + return this; + } + + public Builder firstName(String firstName) { + this.firstName = firstName; + return this; + } + + public Builder lastName(String lastName) { + this.lastName = lastName; + return this; + } + + public Agent build() { + return new Agent(this); + } + } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Claim.java b/src/main/java/sf/codingcompetition2020/structures/Claim.java index 581140a..7ed9a95 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Claim.java +++ b/src/main/java/sf/codingcompetition2020/structures/Claim.java @@ -5,5 +5,125 @@ public class Claim { private int customerId; private boolean closed; private int monthsOpen; - + + /** + * Default Claim constructor + */ + public Claim(int claimId, int customerId, boolean closed, int monthsOpen) { + this.claimId = claimId; + this.customerId = customerId; + this.closed = closed; + this.monthsOpen = monthsOpen; + } + + /** + * Builder constructor + * @param builder + */ + public Claim(Builder builder) { + this( + builder.claimId, + builder.customerId, + builder.closed, + builder.monthsOpen); + } + + /** + * Returns value of claimId + * @return + */ + public int getClaimId() { + return claimId; + } + + /** + * Sets new value of claimId + * @param + */ + public void setClaimId(int claimId) { + this.claimId = claimId; + } + + /** + * Returns value of customerId + * @return + */ + public int getCustomerId() { + return customerId; + } + + /** + * Sets new value of customerId + * @param + */ + public void setCustomerId(int customerId) { + this.customerId = customerId; + } + + /** + * Returns value of closed + * @return + */ + public boolean isClosed() { + return closed; + } + + /** + * Sets new value of closed + * @param + */ + public void setClosed(boolean closed) { + this.closed = closed; + } + + /** + * Returns value of monthsOpen + * @return + */ + public int getMonthsOpen() { + return monthsOpen; + } + + /** + * Sets new value of monthsOpen + * @param + */ + public void setMonthsOpen(int monthsOpen) { + this.monthsOpen = monthsOpen; + } + + public static class Builder { + private int claimId; + private int customerId; + private boolean closed; + private int monthsOpen; + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder claimId(int claimId) { + this.claimId = claimId; + return this; + } + + public Builder customerId(int customerId) { + this.customerId = customerId; + return this; + } + + public Builder closed(boolean closed) { + this.closed = closed; + return this; + } + + public Builder monthsOpen(int monthsOpen) { + this.monthsOpen = monthsOpen; + return this; + } + + public Claim build() { + return new Claim(this); + } + } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Customer.java b/src/main/java/sf/codingcompetition2020/structures/Customer.java index f151906..7b44af9 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Customer.java +++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java @@ -24,4 +24,392 @@ public class Customer { private short yearsOfService; private Integer vehiclesInsured; + /** + * Default Customer constructor + */ + public Customer(int customerId, String firstName, String lastName, int age, String area, int agentId, short agentRating, String primaryLanguage, List dependents, boolean homePolicy, boolean autoPolicy, boolean rentersPolicy, String totalMonthlyPremium, short yearsOfService, Integer vehiclesInsured) { + this.customerId = customerId; + this.firstName = firstName; + this.lastName = lastName; + this.age = age; + this.area = area; + this.agentId = agentId; + this.agentRating = agentRating; + this.primaryLanguage = primaryLanguage; + this.dependents = dependents; + this.homePolicy = homePolicy; + this.autoPolicy = autoPolicy; + this.rentersPolicy = rentersPolicy; + this.totalMonthlyPremium = totalMonthlyPremium; + this.yearsOfService = yearsOfService; + this.vehiclesInsured = vehiclesInsured; + } + + /** + * Builder constructor + * @param builder + */ + public Customer(Builder builder) { + this( + builder.customerId, + builder.firstName, + builder.lastName, + builder.age, + builder.area, + builder.agentId, + builder.agentRating, + builder.primaryLanguage, + builder.dependents, + builder.homePolicy, + builder.autoPolicy, + builder.rentersPolicy, + builder.totalMonthlyPremium, + builder.yearsOfService, + builder.vehiclesInsured); + } + + /** + * Returns value of customerId + * @return + */ + public int getCustomerId() { + return customerId; + } + + /** + * Sets new value of customerId + * @param + */ + public void setCustomerId(int customerId) { + this.customerId = customerId; + } + + /** + * Returns value of firstName + * @return + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets new value of firstName + * @param + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * Returns value of lastName + * @return + */ + public String getLastName() { + return lastName; + } + + /** + * Sets new value of lastName + * @param + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * Returns value of age + * @return + */ + public int getAge() { + return age; + } + + /** + * Sets new value of age + * @param + */ + public void setAge(int age) { + this.age = age; + } + + /** + * Returns value of area + * @return + */ + public String getArea() { + return area; + } + + /** + * Sets new value of area + * @param + */ + public void setArea(String area) { + this.area = area; + } + + /** + * Returns value of agentId + * @return + */ + public int getAgentId() { + return agentId; + } + + /** + * Sets new value of agentId + * @param + */ + public void setAgentId(int agentId) { + this.agentId = agentId; + } + + /** + * Returns value of agentRating + * @return + */ + public short getAgentRating() { + return agentRating; + } + + /** + * Sets new value of agentRating + * @param + */ + public void setAgentRating(short agentRating) { + this.agentRating = agentRating; + } + + /** + * Returns value of primaryLanguage + * @return + */ + public String getPrimaryLanguage() { + return primaryLanguage; + } + + /** + * Sets new value of primaryLanguage + * @param + */ + public void setPrimaryLanguage(String primaryLanguage) { + this.primaryLanguage = primaryLanguage; + } + + /** + * Returns value of dependents + * @return + */ + public List getDependents() { + return dependents; + } + + /** + * Sets new value of dependents + * @param + */ + public void setDependents(List dependents) { + this.dependents = dependents; + } + + /** + * Returns value of homePolicy + * @return + */ + public boolean isHomePolicy() { + return homePolicy; + } + + /** + * Sets new value of homePolicy + * @param + */ + public void setHomePolicy(boolean homePolicy) { + this.homePolicy = homePolicy; + } + + /** + * Returns value of autoPolicy + * @return + */ + public boolean isAutoPolicy() { + return autoPolicy; + } + + /** + * Sets new value of autoPolicy + * @param + */ + public void setAutoPolicy(boolean autoPolicy) { + this.autoPolicy = autoPolicy; + } + + /** + * Returns value of rentersPolicy + * @return + */ + public boolean isRentersPolicy() { + return rentersPolicy; + } + + /** + * Sets new value of rentersPolicy + * @param + */ + public void setRentersPolicy(boolean rentersPolicy) { + this.rentersPolicy = rentersPolicy; + } + + /** + * Returns value of totalMonthlyPremium + * @return + */ + public String getTotalMonthlyPremium() { + return totalMonthlyPremium; + } + + /** + * Sets new value of totalMonthlyPremium + * @param + */ + public void setTotalMonthlyPremium(String totalMonthlyPremium) { + this.totalMonthlyPremium = totalMonthlyPremium; + } + + /** + * Returns value of yearsOfService + * @return + */ + public short getYearsOfService() { + return yearsOfService; + } + + /** + * Sets new value of yearsOfService + * @param + */ + public void setYearsOfService(short yearsOfService) { + this.yearsOfService = yearsOfService; + } + + /** + * Returns value of vehiclesInsured + * @return + */ + public Integer getVehiclesInsured() { + return vehiclesInsured; + } + + /** + * Sets new value of vehiclesInsured + * @param + */ + public void setVehiclesInsured(Integer vehiclesInsured) { + this.vehiclesInsured = vehiclesInsured; + } + + public static class Builder { + private int customerId; + private String firstName; + private String lastName; + private int age; + private String area; + private int agentId; + private short agentRating; + private String primaryLanguage; + private List dependents; + private boolean homePolicy; + private boolean autoPolicy; + private boolean rentersPolicy; + private String totalMonthlyPremium; + private short yearsOfService; + private Integer vehiclesInsured; + + public static Builder newBuilder() { + return new Builder(); + } + + + public static Builder newBuilder() { + return new Builder(); + } + public Builder customerId(int customerId) { + this.customerId = customerId; + return this; + } + + public Builder firstName(String firstName) { + this.firstName = firstName; + return this; + } + + public Builder lastName(String lastName) { + this.lastName = lastName; + return this; + } + + public Builder age(int age) { + this.age = age; + return this; + } + + public Builder area(String area) { + this.area = area; + return this; + } + + public Builder agentId(int agentId) { + this.agentId = agentId; + return this; + } + + public Builder agentRating(short agentRating) { + this.agentRating = agentRating; + return this; + } + + public Builder primaryLanguage(String primaryLanguage) { + this.primaryLanguage = primaryLanguage; + return this; + } + + public Builder dependents(List dependents) { + this.dependents = dependents; + return this; + } + + public Builder homePolicy(boolean homePolicy) { + this.homePolicy = homePolicy; + return this; + } + + public Builder autoPolicy(boolean autoPolicy) { + this.autoPolicy = autoPolicy; + return this; + } + + public Builder rentersPolicy(boolean rentersPolicy) { + this.rentersPolicy = rentersPolicy; + return this; + } + + public Builder totalMonthlyPremium(String totalMonthlyPremium) { + this.totalMonthlyPremium = totalMonthlyPremium; + return this; + } + + public Builder yearsOfService(short yearsOfService) { + this.yearsOfService = yearsOfService; + return this; + } + + public Builder vehiclesInsured(Integer vehiclesInsured) { + this.vehiclesInsured = vehiclesInsured; + return this; + } + + public Customer build() { + return new Customer(this); + } + } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Dependent.java b/src/main/java/sf/codingcompetition2020/structures/Dependent.java index d4deb1a..90906c0 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Dependent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Dependent.java @@ -4,4 +4,74 @@ public class Dependent { private String firstName; private String lastName; + /** + * Default Dependent constructor + */ + public Dependent(String firstName, String lastName) { + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Builder constructor + * @param builder + */ + public Dependent(Builder builder) { + this(builder.firstName, builder.lastName); + } + + /** + * Returns value of firstName + * @return + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets new value of firstName + * @param + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * Returns value of lastName + * @return + */ + public String getLastName() { + return lastName; + } + + /** + * Sets new value of lastName + * @param + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public static class Builder { + private String firstName; + private String lastName; + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder firstName(String firstName) { + this.firstName = firstName; + return this; + } + + public Builder lastName(String lastName) { + this.lastName = lastName; + return this; + } + + public Dependent build() { + return new Dependent(this); + } + } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Vendor.java b/src/main/java/sf/codingcompetition2020/structures/Vendor.java index 6b6fb76..d14c92e 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Vendor.java +++ b/src/main/java/sf/codingcompetition2020/structures/Vendor.java @@ -5,5 +5,125 @@ public class Vendor { private String area; private int vendorRating; private boolean inScope; - + + /** + * Default Vendor constructor + */ + public Vendor(int vendorId, String area, int vendorRating, boolean inScope) { + this.vendorId = vendorId; + this.area = area; + this.vendorRating = vendorRating; + this.inScope = inScope; + } + + /** + * Builder constructor + * @param builder + */ + public Vendor(Builder builder) { + this( + builder.vendorId, + builder.area, + builder.vendorRating, + builder.inScope); + } + + /** + * Returns value of vendorId + * @return + */ + public int getVendorId() { + return vendorId; + } + + /** + * Sets new value of vendorId + * @param + */ + public void setVendorId(int vendorId) { + this.vendorId = vendorId; + } + + /** + * Returns value of area + * @return + */ + public String getArea() { + return area; + } + + /** + * Sets new value of area + * @param + */ + public void setArea(String area) { + this.area = area; + } + + /** + * Returns value of vendorRating + * @return + */ + public int getVendorRating() { + return vendorRating; + } + + /** + * Sets new value of vendorRating + * @param + */ + public void setVendorRating(int vendorRating) { + this.vendorRating = vendorRating; + } + + /** + * Returns value of inScope + * @return + */ + public boolean isInScope() { + return inScope; + } + + /** + * Sets new value of inScope + * @param + */ + public void setInScope(boolean inScope) { + this.inScope = inScope; + } + + public static class Builder { + private int vendorId; + private String area; + private int vendorRating; + private boolean inScope; + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder vendorId(int vendorId) { + this.vendorId = vendorId; + return this; + } + + public Builder area(String area) { + this.area = area; + return this; + } + + public Builder vendorRating(int vendorRating) { + this.vendorRating = vendorRating; + return this; + } + + public Builder inScope(boolean inScope) { + this.inScope = inScope; + return this; + } + + public Vendor build() { + return new Vendor(this); + } + } } From afe45043f219d58d1bc59b7e33960636006f9ad6 Mon Sep 17 00:00:00 2001 From: mniverthi Date: Sat, 10 Oct 2020 21:42:44 -0400 Subject: [PATCH 02/26] methods 9 and 10 --- .../CodingCompCsvUtil.java | 37 ++++++++++++++---- .../structures/Claim.java | 4 +- target/classes/META-INF/MANIFEST.MF | 5 --- .../coding-competition/pom.properties | 7 ---- .../coding-competition/pom.xml | 32 --------------- .../CodingCompCsvUtil.class | Bin 3251 -> 0 bytes .../structures/Agent.class | Bin 428 -> 0 bytes .../structures/Claim.class | Bin 397 -> 0 bytes .../structures/Customer.class | Bin 806 -> 0 bytes .../structures/Dependent.class | Bin 384 -> 0 bytes .../structures/Vendor.class | Bin 419 -> 0 bytes .../CodingCompCsvUtilTest.class | Bin 3972 -> 0 bytes 12 files changed, 33 insertions(+), 52 deletions(-) delete mode 100644 target/classes/META-INF/MANIFEST.MF delete mode 100644 target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties delete mode 100644 target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.xml delete mode 100644 target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class delete mode 100644 target/classes/sf/codingcompetition2020/structures/Agent.class delete mode 100644 target/classes/sf/codingcompetition2020/structures/Claim.class delete mode 100644 target/classes/sf/codingcompetition2020/structures/Customer.class delete mode 100644 target/classes/sf/codingcompetition2020/structures/Dependent.class delete mode 100644 target/classes/sf/codingcompetition2020/structures/Vendor.class delete mode 100644 target/test-classes/sf/codingcompetition2020/CodingCompCsvUtilTest.class diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 58267da..42dc329 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -2,10 +2,8 @@ import java.io.FileReader; import java.io.Reader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.lang.reflect.Array; +import java.util.*; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -130,7 +128,21 @@ public List getUndisclosedDrivers(String filePath, int vehiclesInsured * @return -- Agent ID of agent with the given rank. */ public int getAgentIdGivenRank(String filePath, int agentRank) { - + List allCustomers = readCsvFile(filePath, Customer.class); + int numberOfAgents = Integer.MIN_VALUE; + for (Customer currentCustomer : allCustomers) { + numberOfAgents = Math.min(numberOfAgents, currentCustomer.getAgentId()); + } + int[] totalAgentRating = new int[numberOfAgents + 1]; + int[] numberOfAgentReviews = new int[numberOfAgents + 1]; + int[] agentIdNumbers = new int[numberOfAgents + 1]; + for (int i = 0; i < agentIdNumbers.length; i++) { + agentIdNumbers[i] = i; + } + for (Customer currentCustomer : allCustomers) { + totalAgentRating[] + } + return agentIdNumbers[agentRank - 1]; } @@ -140,8 +152,19 @@ public int getAgentIdGivenRank(String filePath, int agentRank) { * @param monthsOpen -- Number of months a policy has been open. * @return -- List of customers who’ve filed a claim within the last . */ - public List getCustomersWithClaims(Map csvFilePaths, short monthsOpen) { - + public List getCustomersWithClaims(Map csvFilePaths, short monthsOpen) { + String customerListFilePath = csvFilePaths.get("customerList"); + String claimsListFilePath = csvFilePaths.get("claimList"); + List allCustomers = readCsvFile(customerListFilePath, Customer.class); + List allClaims = readCsvFile(claimsListFilePath, Claim.class); + List customersWithClaims = new ArrayList(); + for (Claim currentClaim : allClaims) { + if (currentClaim.getMonthsOpen() <= monthsOpen) { + int currentClaimCustomerId = currentClaim.getCustomerId(); + customersWithClaims.add(allCustomers.get(currentClaimCustomerId)); + } + } + return customersWithClaims; } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Claim.java b/src/main/java/sf/codingcompetition2020/structures/Claim.java index 581140a..c75d4ef 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Claim.java +++ b/src/main/java/sf/codingcompetition2020/structures/Claim.java @@ -1,9 +1,11 @@ package sf.codingcompetition2020.structures; public class Claim { + private int claimId; private int customerId; private boolean closed; private int monthsOpen; - + + } diff --git a/target/classes/META-INF/MANIFEST.MF b/target/classes/META-INF/MANIFEST.MF deleted file mode 100644 index e2a1a34..0000000 --- a/target/classes/META-INF/MANIFEST.MF +++ /dev/null @@ -1,5 +0,0 @@ -Manifest-Version: 1.0 -Built-By: yc1d -Build-Jdk: 1.8.0_201 -Created-By: Maven Integration for Eclipse - diff --git a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties b/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties deleted file mode 100644 index fe569e3..0000000 --- a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties +++ /dev/null @@ -1,7 +0,0 @@ -#Generated by Maven Integration for Eclipse -#Thu Oct 08 09:27:33 MST 2020 -version=1.0.0-SNAPSHOT -groupId=sf.codingcompetition2020 -m2e.projectName=coding-competition -m2e.projectLocation=/Users/yc1d/Development/coding-competition/problem/online-competition -artifactId=coding-competition diff --git a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.xml b/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.xml deleted file mode 100644 index 21d55bf..0000000 --- a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - 4.0.0 - coding-competition - 1.0.0-SNAPSHOT - jar - sf.codingcompetition2020 - - coding-competition - Coding Competition - - - - - - - junit - junit - 4.12 - test - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-csv - 2.11.2 - - - - diff --git a/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class b/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class deleted file mode 100644 index 00daba9d49249e6950fa6b4b75732ac294bb504b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3251 zcmb`JU2_{X6o!x7q;a-|mb3}wdmH)@x1~-)OG|7#6I=qGF$8KmrMXjf6YW-y&%b{C9RTh@Z3zklZt0_PBx5eR zk?aqc;f71GwYjxfu4kil9Ifl)j^W7?ED*T(oF3D1LPfW{clew|hQQe>7u?hcoY^St z6Ij3(Spa8X`8+JbSppZDT(ED_{vlIsdYCW*D@_^EWS=T-??;0RrpGmbJI(xxDg@3c zMq?DX%Psi9MsuRCWfZ1WnHs4lRO?DskUoD04wmOwf_o%RgZF8r%PRCcDhWMx=e*> zh#hp2z)er|lp7;YON}DDOJHw~(z!4Jfp9EJ4+XV*)U*bSzGz~{rL>Fn`6`z}kLKC3 zr*lG8U){6Xs5G*TrOTPw*dRr?O5o`nt;?#O(Q9bodSvTa$2O6Dru43oeOp@VWJj|s zY+_Yy`ty@-ljx)_wb{`Tf$N^eX?fO_PM)}Y-7}V!HPCGW2XnL_YoPH5Y!6*V zFPgZpYRtbObgHO`aOz$2q~poDog?gjCyh%JirQx)mP$Y6ruQX3X5tC1m7;5V8+*JV zT9F)}&PN^rvpsmw@Mu3e<*WJf8OqN}_%VU+=Uu`f-WG5bz3PaV>nM?$#g7%5rSR{1 z!;@aa=fi%kz)RrYd5?eaYI)X6mlp3cyvsT@&uc0M6kR?w0Vlgm+~;6Fe{8dI`l} z@S*?#9_?d*D;NxLei(q~*YJ+O>u>?1F5-0o-pC;L5pChYZ?N)g5d`y+cgA%#<< zz>(g9w~=RM{FCsGhj80Vcn{upT0U^31*awSkREzT>+qo?U2~*GN4oAIJ@%4r!iFQ2 z9BJYYIz8jho|kk7K60eHj#O}(e53;}sSKNrbkC6{*=>0=aWCmUJaD8>9BJaXPty-x g(nENZyZS$Q37^8Y(^7F-{@dxFy`(C7T7b{~2FpNm>;M1& diff --git a/target/classes/sf/codingcompetition2020/structures/Agent.class b/target/classes/sf/codingcompetition2020/structures/Agent.class deleted file mode 100644 index 26bf31f236fb6fb54997543cc9d682faad0ab137..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 428 zcma)2O-sW-5Pj3crj60o`gQhZ6-@0_5kwFQp&lx|Z_;htk`LKz{9m2~5B>mulsFqB zUOnu*H?!{zGxPcN{sG_;#~wO_akUPUa;1tiDf4G(lu>0dolGZTWptgGTFWZDO=V#` zxP;+GyofLpMH)WD8<`k_C+zQRMW7kM6^qsa^_tA zrQK^)D04$_PRC1bc2};X4+p~l0d@$3NELEk=dsj}BF@-6ipoS}OQDs`+oEfpR7E(C z{=FPe=P$}yC-Pp|wtlnng8Fucq(f)zZ zx*X04@x(4wiWYiZ9H2|+<=UvHx?HI0MJx(M801!pVlFBj_)d)dT06pZ{_hrd9OT*7 zl~j*9JexM%ZbB_wfb;O*#E8&FhqnmH4)?I%@U-FFDCFdM$ZEz&jP0vW9DOureV(00 UY~h&qaLNZ5;DnKI$}_^*9}Y)V@c;k- diff --git a/target/classes/sf/codingcompetition2020/structures/Customer.class b/target/classes/sf/codingcompetition2020/structures/Customer.class deleted file mode 100644 index 844ea29474f5bc9dd328dee078d97b0567ad1de8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 806 zcma)4$!^;)5PkF-D|Vd5-S;%r9cj z!U!9l6xQinm@Zljn^%0v!;GsmJeypJ#4!YkPZ&=b*qEU=lg7GJo(qPp=x;&n40SqW zSj%`FZ}OC~THFZE&?TT;NwZ#ApShy~B8?e_3nO!GRuQ!>s-j>j7D7#_!qQxS`V>xP zVI-}iF1=W$ikCYuy#FtJ6kTWY4|RjXW8w?ubcJ)B$z(+%eIW-goUR=MLxTuoYdmt= z@$8dUZl0~qjmTw@Gix5^Q+{hApXUokcU2E@J>(>uo z?jGyHB;uninFn=XuY6l zd?VtyiCdL@+v_`C-}U+TeEoeqpgek(@){%`6ACK~wBLNgldl!cHpvdTfdJ1)_A9%M O9qbZfcuul`7ry~KU%=}C diff --git a/target/classes/sf/codingcompetition2020/structures/Dependent.class b/target/classes/sf/codingcompetition2020/structures/Dependent.class deleted file mode 100644 index 3ee505f7dda4d5aad7c64d98dd9748ea80a0698b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 384 zcmb7A%TB{E5F9sY(uUBM@&()g30!&waRG6P%Au%tCvl6b#I78N|Kfzife+xL5F7J4 zBTGBGJEPI8-#=d809@cOMvvjFS@Xh_N^c5N@1#>s89krPXS{K?EnI75!*AtI>QZVK zBV?Ft#gpKb&>McAZ)M>ahHGUTw-B{tm}YZ1I6hf1gg2&? z2?C@k1{gAoGo|ICt#fG~L|%DEQ;2FMtm@|PW#}GN!@#qD9Y9f%rD<&;?^I_!`aSKu zON}E?F8ZDxy*?t}#U2?kl#gmcTTaLb`=>A1d-k$@s*zs?7*U^o2{6WlCWZsAntlR( CuUa4g diff --git a/target/classes/sf/codingcompetition2020/structures/Vendor.class b/target/classes/sf/codingcompetition2020/structures/Vendor.class deleted file mode 100644 index fdbca9b6e0183e880547b8ff174552c31967ec4f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 419 zcma)&&rSj{5XQe*78YR@#D8aRN{owKHC{|iNH&^?;oz-wE0#b@x?SGOlZgi(z=tx< zE+k&Pe4XEPW;$QLe?GqeT;U`_KSP&+%H@SHoFsTOMJ#)z>?=%m`HhhjNZ?paJ1+|^616pM*)y5wy#^lv&R zT%`YZ#+$Xqws2D2>vC>;WB9UkfK%{B{9_>k)Y0H5K!j#>?rgb*HZ$8OH)Y*pN-75G e{SS2BtMYx;2B*OTd#rI4*KvSDCc+VGfa70hyb_Eo87v*2~*U; zK~esVxqkafPc6 z!yaXs8_u+*^IM8jVo2m0duAPr;Lp>htZCSeVmJjwuka{383t`j&6E|*$XMJqE0)Ub z%#`9N0?E#}p!Tq8S4mmb6|Edth(damvb*0`?olhYW0twq(C=nQ?`S+w@gd?>ZWPTX zfCNKoM*vU3SMPMslGkh}iav%;mz^i}Gf06kZ)Pt;uNM^0{RQEEh7$zM351F+;tAcFpNXO;FyH{IKa@I*9?B6QeNcNoU*8MkvgWT=mo{ngzQhYIVH_z z7`$YdN!0A$Mh5wFpSFyOF|| zEz7i`_<-T>c|&BXUgbquRE(y(Ao7}J5^C9=kYk;5B`%k_Q!n>H>qd8YnoY^(5 ztmdg@Rj3f7m}mIwwIk_bz9Jm%o~_~d9~2pms3I^yOzmmQEN3-m-J!$J+uWrP#U~7R zcRsgB;K2(Q2W4}OTZ%(DN=Zw#A}hLXKJ?SpYt^#Ot6Y~CIW5Se!)Ia)L*)88g&FQp zXXnLf(^}w)WnWsqrK{^%({?6pHHv$T{kSuikZKCRUlE32+tx_9JZ>({a;vJTJ6Gg( z5OdTw^y{YKl=Ssm7B6d+^3DYsRM{K#h3#16m0dKI?Udj62nLtgP$=sL@YtL}UkRPYFj3~{&H)>kAfVVN#1TYE%z0^MLa z>Lz5n;NHUa9nC3S(ddSqq4sMmiwdWPlrv^kO51==R}^$>dTnW3P%|WyU^1Kyq4siH zx|@56Zh+hp45TP3fr(Re6Ye_w#{z_ILF|!)FYy&MU(%m9ikhwJrp=2}79G)|c6U64 zaBh2g@uqg2EBbyiRs)l*!sNFS9^*TPfiP&{?StYhn_7x+x_jLaqu8wbS`+Unh6AB* z#bFUq9Hz^@mF|cr65_EzQiP-ySEeUNUGAcFdU(|3ILY+}1VqXm>(l0Q)@EjvGjQ&L0EjUHrG(DPtZnUA7MuKl229P9M{WwCS6fqhm z4(DjkY1%1ymNAa^Nn$udJ6mv;#)9`b`WFmO`wU|*FtL!h@EjNapjpqN*asYHLW|YW zCPUHgkk^IIu_P{~f5vDcnwZ+a^wVFEOX8+KbK9S394+n!ZIBL?!ch!089Y`uI2&qk zGyS;``Xfzf4f=&$pxp^UJ0FU+unV-iA!t`a(e8($O;O;5YX_2e;5stCfzN)$B7^X5 z!6Ivt3zbBu!;D`SJu06wI From 8da36e6b7c0c63e813672bcbac3c4210a2354d4a Mon Sep 17 00:00:00 2001 From: mniverthi Date: Sat, 10 Oct 2020 22:12:57 -0400 Subject: [PATCH 03/26] finished 9 --- .../CodingCompCsvUtil.java | 45 ++++++++++++++----- .../codingcompetition2020/utilities/Pair.java | 28 ++++++++++++ 2 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 src/main/java/sf/codingcompetition2020/utilities/Pair.java diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 33276e1..d284a51 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -26,6 +26,7 @@ import sf.codingcompetition2020.structures.Claim; import sf.codingcompetition2020.structures.Customer; import sf.codingcompetition2020.structures.Vendor; +import sf.codingcompetition2020.utilities.Pair; public class CodingCompCsvUtil { @@ -154,16 +155,39 @@ public int getAgentIdGivenRank(String filePath, int agentRank) { for (Customer currentCustomer : allCustomers) { numberOfAgents = Math.min(numberOfAgents, currentCustomer.getAgentId()); } - int[] totalAgentRating = new int[numberOfAgents + 1]; - int[] numberOfAgentReviews = new int[numberOfAgents + 1]; - int[] agentIdNumbers = new int[numberOfAgents + 1]; - for (int i = 0; i < agentIdNumbers.length; i++) { - agentIdNumbers[i] = i; - } + Map> agentRatingsList = new HashMap<>(); for (Customer currentCustomer : allCustomers) { - totalAgentRating[] + int currentAgentId = currentCustomer.getAgentId(); + int currentAgentRating = currentCustomer.getAgentRating(); + if (agentRatingsList.containsKey(currentAgentId)) { + List currentAgentList = agentRatingsList.get(currentAgentId); + currentAgentList.set(0, currentAgentList.get(0) + 1); + currentAgentList.set(1, currentAgentList.get(1) + currentAgentRating); + agentRatingsList.put(currentAgentId, currentAgentList); + } else { + List newAgentList = new ArrayList<>(); + newAgentList.add(1); + newAgentList.add(currentAgentRating); + agentRatingsList.put(currentAgentId, newAgentList); + } } - return agentIdNumbers[agentRank - 1]; + List> agentAverageRatings = new ArrayList<>(); + for (Map.Entry> entry : agentRatingsList.entrySet()) { + Integer agentId = entry.getKey(); + Integer numReviews = entry.getValue().get(0); + Integer totalRating = entry.getValue().get(1); + Double averageRating = (double)(totalRating) / numReviews; + agentAverageRatings.add(new Pair<>(agentId, averageRating)); + } + Collections.sort(agentAverageRatings, (o1, o2) -> { + if (o1.getValue2() > o2.getValue2()) { + return 1; + } else if (o1.getValue2() > o2.getValue2()) { + return -1; + } + return 0; + }); + return agentAverageRatings.get(agentRank - 1).getValue1(); } @@ -178,7 +202,7 @@ public List getCustomersWithClaims(Map csvFilePaths, s String claimsListFilePath = csvFilePaths.get("claimList"); List allCustomers = readCsvFile(customerListFilePath, Customer.class); List allClaims = readCsvFile(claimsListFilePath, Claim.class); - List customersWithClaims = new ArrayList(); + List customersWithClaims = new ArrayList<>(); for (Claim currentClaim : allClaims) { if (currentClaim.getMonthsOpen() <= monthsOpen) { int currentClaimCustomerId = currentClaim.getCustomerId(); @@ -186,6 +210,5 @@ public List getCustomersWithClaims(Map csvFilePaths, s } } return customersWithClaims; - } - + } } diff --git a/src/main/java/sf/codingcompetition2020/utilities/Pair.java b/src/main/java/sf/codingcompetition2020/utilities/Pair.java new file mode 100644 index 0000000..20dc438 --- /dev/null +++ b/src/main/java/sf/codingcompetition2020/utilities/Pair.java @@ -0,0 +1,28 @@ +package sf.codingcompetition2020.utilities; + +public class Pair { + + private T value1; + private V value2; + + public T getValue1() { + return value1; + } + + public void setValue1(T value1) { + this.value1 = value1; + } + + public V getValue2() { + return value2; + } + + public void setValue2(V value2) { + this.value2 = value2; + } + + public Pair(T value1, V value2) { + this.value1 = value1; + this.value2 = value2; + } +} From 4a61fb87fd49a14462182806e1412956997e44c9 Mon Sep 17 00:00:00 2001 From: mniverthi Date: Sat, 10 Oct 2020 22:16:28 -0400 Subject: [PATCH 04/26] finished 8 --- .../sf/codingcompetition2020/CodingCompCsvUtil.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index d284a51..5eecc58 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -137,7 +137,17 @@ public List getVendorsWithGivenRatingThatAreInScope(String filePath, Str * @return -- List of customers filtered by age, number of vehicles insured and the number of dependents. */ public List getUndisclosedDrivers(String filePath, int vehiclesInsured, int dependents) { + List allCustomers = readCsvFile(filePath, Customer.class); + List filteredCustomers = new ArrayList<>(); + for (Customer current : allCustomers) { + if (current.getAge() >= 40 && current.getAge() <= 50) { + if (current.getVehiclesInsured() > vehiclesInsured && current.getDependents().size() <= dependents) { + filteredCustomers.add(current); + } + } + } + return filteredCustomers; } From aef45c3b4410426cdbb39d9f462c32598667fe66 Mon Sep 17 00:00:00 2001 From: mniverthi Date: Sat, 10 Oct 2020 22:23:22 -0400 Subject: [PATCH 05/26] finished 7 --- .../codingcompetition2020/CodingCompCsvUtil.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 5eecc58..811378e 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -123,7 +123,20 @@ b. Whether that vendor is in scope of the insurance (if inScope == false, return * @return -- List of vendors within a given area, filtered by scope and vendor rating. */ public List getVendorsWithGivenRatingThatAreInScope(String filePath, String area, boolean inScope, int vendorRating) { - + List allVendors = readCsvFile(filePath, Vendor.class); + List narrowedVendors = new ArrayList<>(); + for (Vendor current : allVendors) { + if (current.getVendorRating() == vendorRating && area.equals(current.getArea())) { + if (inScope) { + if (current.isInScope()) { + narrowedVendors.add(current); + } + } else { + narrowedVendors.add(current); + } + } + } + return narrowedVendors; } @@ -145,7 +158,6 @@ public List getUndisclosedDrivers(String filePath, int vehiclesInsured filteredCustomers.add(current); } } - } return filteredCustomers; } From 8a5850b137b17e45c698d1ab756e0fec4224e9db Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sat, 10 Oct 2020 22:24:44 -0400 Subject: [PATCH 06/26] csv mapper?? --- feedback.txt | 2 + .../CodingCompCsvUtil.java | 44 ++++++++++++------ .../structures/Agent.java | 15 ++++++ .../structures/Claim.java | 14 ++++++ .../structures/Customer.java | 40 ++++++++++++---- target/classes/META-INF/MANIFEST.MF | 5 -- .../coding-competition/pom.properties | 7 --- .../coding-competition/pom.xml | 32 ------------- .../CodingCompCsvUtil.class | Bin 3251 -> 0 bytes .../structures/Agent.class | Bin 428 -> 0 bytes .../structures/Claim.class | Bin 397 -> 0 bytes .../structures/Customer.class | Bin 806 -> 0 bytes .../structures/Dependent.class | Bin 384 -> 0 bytes .../structures/Vendor.class | Bin 419 -> 0 bytes .../CodingCompCsvUtilTest.class | Bin 3972 -> 0 bytes 15 files changed, 90 insertions(+), 69 deletions(-) delete mode 100644 target/classes/META-INF/MANIFEST.MF delete mode 100644 target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties delete mode 100644 target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.xml delete mode 100644 target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class delete mode 100644 target/classes/sf/codingcompetition2020/structures/Agent.class delete mode 100644 target/classes/sf/codingcompetition2020/structures/Claim.class delete mode 100644 target/classes/sf/codingcompetition2020/structures/Customer.class delete mode 100644 target/classes/sf/codingcompetition2020/structures/Dependent.class delete mode 100644 target/classes/sf/codingcompetition2020/structures/Vendor.class delete mode 100644 target/test-classes/sf/codingcompetition2020/CodingCompCsvUtilTest.class diff --git a/feedback.txt b/feedback.txt index eda5ea6..fcc031d 100644 --- a/feedback.txt +++ b/feedback.txt @@ -6,6 +6,8 @@ Document and describe any enhancements included to help the judges properly grad Step 2: We made all fileIO related methods and tests throw IOException to account for when a file is not found. If a file is not found, is does not make sense to just return an empty list, as we should instead tell the user that they are attempting to read a non-present file. We also changed some of the tests to throw the IOException. + Step 3: We noticed that the vehiclesInsured field was unnecessarily declared as an Integer in the Customer class, so we converted it to an int. + Step 4: Feedback for the coding competition? Things you would like to see in future events? diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 50a3ad6..04925bc 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -2,6 +2,7 @@ import java.io.FileReader; import java.io.Reader; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -22,6 +23,7 @@ import com.fasterxml.jackson.databind.MappingIterator; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.dataformat.csv.CsvMapper; +import com.fasterxml.jackson.dataformat.csv.CsvParser; import com.fasterxml.jackson.dataformat.csv.CsvSchema; import sf.codingcompetition2020.structures.Agent; @@ -38,19 +40,31 @@ public class CodingCompCsvUtil { * @return -- List of entries being returned. */ public List readCsvFile(String filePath, Class classType) throws IOException { - File file = new File(filePath); - FileReader fr = new FileReader(file); - BufferedReader br = new BufferedReader(fr); - String entry; List interpretedFile = new ArrayList<>(); - while ((entry = br.readLine()) != null) { - List interpretedLine = Arrays.asList(entry.split("\\s*,\\s*")); + + File csvFile = new File(filePath); + CsvMapper mapper = new CsvMapper(); + mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY); + MappingIterator it = mapper.readerFor(Object[].class).readValues(csvFile); + it.forEachRemaining(row -> { try { - interpretedFile.add(classType.getConstructor(List.class).newInstance()); - } catch (NoSuchMethodException nsme) { - nsme.printStackTrace(); + interpretedFile.add(classType.getConstructor(List.class).newInstance(Arrays.asList(row))); + } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); } - } + }); + +// FileReader fr = new FileReader(csvFile); +// BufferedReader br = new BufferedReader(fr); +// String entry; +// while ((entry = br.readLine()) != null) { +// List interpretedLine = Arrays.asList(entry.split("\\s*,\\s*")); +// try { +// interpretedFile.add(classType.getConstructor(List.class).newInstance(interpretedLine)); +// } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { +// e.printStackTrace(); +// } +// } return interpretedFile; } @@ -62,7 +76,7 @@ public List readCsvFile(String filePath, Class classType) throws IOExc * @return -- The number of agents in a given area */ public int getAgentCountInArea(String filePath, String area) { - + return -1; } @@ -74,7 +88,7 @@ public int getAgentCountInArea(String filePath, String area) { * @return -- The number of agents in a given area */ public List getAgentsInAreaThatSpeakLanguage(String filePath, String area, String language) { - + return null; } @@ -87,7 +101,7 @@ public List getAgentsInAreaThatSpeakLanguage(String filePath, String area * @return -- The number of customers that use a certain agent in a given area. */ public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, String customerArea, String agentFirstName, String agentLastName) { - + return -1; } @@ -98,7 +112,7 @@ public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, * @return -- List of customers retained for a given number of years, in ascending order of policy cost. */ public List getCustomersRetainedForYearsByPlcyCostAsc(String customerFilePath, short yearsOfService) { - + return null; } @@ -109,7 +123,7 @@ public List getCustomersRetainedForYearsByPlcyCostAsc(String customerF * @return -- List of customers who’ve made an inquiry for a policy but have not signed up. */ public List getLeadsForInsurance(String filePath) { - + return null; } diff --git a/src/main/java/sf/codingcompetition2020/structures/Agent.java b/src/main/java/sf/codingcompetition2020/structures/Agent.java index 43dd53a..f907ec0 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Agent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Agent.java @@ -1,5 +1,7 @@ package sf.codingcompetition2020.structures; +import java.util.List; + public class Agent { private int agentId; @@ -19,6 +21,19 @@ private Agent(int agentId, String area, String language, String firstName, Strin this.lastName = lastName; } + /** + * constructor based on an entry in a CSV + * @param csvEntry + */ + public Agent(List csvEntry) { + this( + Integer.parseInt(csvEntry.get(0)), + csvEntry.get(1), + csvEntry.get(2), + csvEntry.get(3), + csvEntry.get(4)); + } + /** * Builder constructor * @param builder diff --git a/src/main/java/sf/codingcompetition2020/structures/Claim.java b/src/main/java/sf/codingcompetition2020/structures/Claim.java index 7ed9a95..9a5694d 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Claim.java +++ b/src/main/java/sf/codingcompetition2020/structures/Claim.java @@ -1,5 +1,7 @@ package sf.codingcompetition2020.structures; +import java.util.List; + public class Claim { private int claimId; private int customerId; @@ -16,6 +18,18 @@ public Claim(int claimId, int customerId, boolean closed, int monthsOpen) { this.monthsOpen = monthsOpen; } + /** + * constructor based on an entry in a CSV + * @param csvEntry + */ + public Claim(List csvEntry) { + this( + Integer.parseInt(csvEntry.get(0)), + Integer.parseInt(csvEntry.get(1)), + Boolean.parseBoolean(csvEntry.get(2)), + Integer.parseInt(csvEntry.get(3))); + } + /** * Builder constructor * @param builder diff --git a/src/main/java/sf/codingcompetition2020/structures/Customer.java b/src/main/java/sf/codingcompetition2020/structures/Customer.java index 7b44af9..a038ba7 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Customer.java +++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java @@ -22,12 +22,12 @@ public class Customer { private boolean rentersPolicy; private String totalMonthlyPremium; private short yearsOfService; - private Integer vehiclesInsured; + private int vehiclesInsured; /** * Default Customer constructor */ - public Customer(int customerId, String firstName, String lastName, int age, String area, int agentId, short agentRating, String primaryLanguage, List dependents, boolean homePolicy, boolean autoPolicy, boolean rentersPolicy, String totalMonthlyPremium, short yearsOfService, Integer vehiclesInsured) { + public Customer(int customerId, String firstName, String lastName, int age, String area, int agentId, short agentRating, String primaryLanguage, List dependents, boolean homePolicy, boolean autoPolicy, boolean rentersPolicy, String totalMonthlyPremium, short yearsOfService, int vehiclesInsured) { this.customerId = customerId; this.firstName = firstName; this.lastName = lastName; @@ -45,6 +45,30 @@ public Customer(int customerId, String firstName, String lastName, int age, Stri this.vehiclesInsured = vehiclesInsured; } + /** + * constructor based on an entry in a CSV + * @param csvEntry + */ + public Customer(List csvEntry) { + this( + Integer.parseInt(csvEntry.get(0)), + csvEntry.get(1), + csvEntry.get(2), + Integer.parseInt(csvEntry.get(3)), + csvEntry.get(4), + Integer.parseInt(csvEntry.get(5)), + Short.parseShort(csvEntry.get(6)), + csvEntry.get(7), + (List)(Object)csvEntry.get(8), + Boolean.parseBoolean(csvEntry.get(9)), + Boolean.parseBoolean(csvEntry.get(10)), + Boolean.parseBoolean(csvEntry.get(11)), + csvEntry.get(12), + Short.parseShort(csvEntry.get(13)), + Integer.parseInt(csvEntry.get(14)) + ); + } + /** * Builder constructor * @param builder @@ -296,7 +320,7 @@ public void setYearsOfService(short yearsOfService) { * Returns value of vehiclesInsured * @return */ - public Integer getVehiclesInsured() { + public int getVehiclesInsured() { return vehiclesInsured; } @@ -304,7 +328,7 @@ public Integer getVehiclesInsured() { * Sets new value of vehiclesInsured * @param */ - public void setVehiclesInsured(Integer vehiclesInsured) { + public void setVehiclesInsured(int vehiclesInsured) { this.vehiclesInsured = vehiclesInsured; } @@ -323,16 +347,12 @@ public static class Builder { private boolean rentersPolicy; private String totalMonthlyPremium; private short yearsOfService; - private Integer vehiclesInsured; + private int vehiclesInsured; public static Builder newBuilder() { return new Builder(); } - - public static Builder newBuilder() { - return new Builder(); - } public Builder customerId(int customerId) { this.customerId = customerId; return this; @@ -403,7 +423,7 @@ public Builder yearsOfService(short yearsOfService) { return this; } - public Builder vehiclesInsured(Integer vehiclesInsured) { + public Builder vehiclesInsured(int vehiclesInsured) { this.vehiclesInsured = vehiclesInsured; return this; } diff --git a/target/classes/META-INF/MANIFEST.MF b/target/classes/META-INF/MANIFEST.MF deleted file mode 100644 index e2a1a34..0000000 --- a/target/classes/META-INF/MANIFEST.MF +++ /dev/null @@ -1,5 +0,0 @@ -Manifest-Version: 1.0 -Built-By: yc1d -Build-Jdk: 1.8.0_201 -Created-By: Maven Integration for Eclipse - diff --git a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties b/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties deleted file mode 100644 index fe569e3..0000000 --- a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties +++ /dev/null @@ -1,7 +0,0 @@ -#Generated by Maven Integration for Eclipse -#Thu Oct 08 09:27:33 MST 2020 -version=1.0.0-SNAPSHOT -groupId=sf.codingcompetition2020 -m2e.projectName=coding-competition -m2e.projectLocation=/Users/yc1d/Development/coding-competition/problem/online-competition -artifactId=coding-competition diff --git a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.xml b/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.xml deleted file mode 100644 index 21d55bf..0000000 --- a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - 4.0.0 - coding-competition - 1.0.0-SNAPSHOT - jar - sf.codingcompetition2020 - - coding-competition - Coding Competition - - - - - - - junit - junit - 4.12 - test - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-csv - 2.11.2 - - - - diff --git a/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class b/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class deleted file mode 100644 index 00daba9d49249e6950fa6b4b75732ac294bb504b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3251 zcmb`JU2_{X6o!x7q;a-|mb3}wdmH)@x1~-)OG|7#6I=qGF$8KmrMXjf6YW-y&%b{C9RTh@Z3zklZt0_PBx5eR zk?aqc;f71GwYjxfu4kil9Ifl)j^W7?ED*T(oF3D1LPfW{clew|hQQe>7u?hcoY^St z6Ij3(Spa8X`8+JbSppZDT(ED_{vlIsdYCW*D@_^EWS=T-??;0RrpGmbJI(xxDg@3c zMq?DX%Psi9MsuRCWfZ1WnHs4lRO?DskUoD04wmOwf_o%RgZF8r%PRCcDhWMx=e*> zh#hp2z)er|lp7;YON}DDOJHw~(z!4Jfp9EJ4+XV*)U*bSzGz~{rL>Fn`6`z}kLKC3 zr*lG8U){6Xs5G*TrOTPw*dRr?O5o`nt;?#O(Q9bodSvTa$2O6Dru43oeOp@VWJj|s zY+_Yy`ty@-ljx)_wb{`Tf$N^eX?fO_PM)}Y-7}V!HPCGW2XnL_YoPH5Y!6*V zFPgZpYRtbObgHO`aOz$2q~poDog?gjCyh%JirQx)mP$Y6ruQX3X5tC1m7;5V8+*JV zT9F)}&PN^rvpsmw@Mu3e<*WJf8OqN}_%VU+=Uu`f-WG5bz3PaV>nM?$#g7%5rSR{1 z!;@aa=fi%kz)RrYd5?eaYI)X6mlp3cyvsT@&uc0M6kR?w0Vlgm+~;6Fe{8dI`l} z@S*?#9_?d*D;NxLei(q~*YJ+O>u>?1F5-0o-pC;L5pChYZ?N)g5d`y+cgA%#<< zz>(g9w~=RM{FCsGhj80Vcn{upT0U^31*awSkREzT>+qo?U2~*GN4oAIJ@%4r!iFQ2 z9BJYYIz8jho|kk7K60eHj#O}(e53;}sSKNrbkC6{*=>0=aWCmUJaD8>9BJaXPty-x g(nENZyZS$Q37^8Y(^7F-{@dxFy`(C7T7b{~2FpNm>;M1& diff --git a/target/classes/sf/codingcompetition2020/structures/Agent.class b/target/classes/sf/codingcompetition2020/structures/Agent.class deleted file mode 100644 index 26bf31f236fb6fb54997543cc9d682faad0ab137..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 428 zcma)2O-sW-5Pj3crj60o`gQhZ6-@0_5kwFQp&lx|Z_;htk`LKz{9m2~5B>mulsFqB zUOnu*H?!{zGxPcN{sG_;#~wO_akUPUa;1tiDf4G(lu>0dolGZTWptgGTFWZDO=V#` zxP;+GyofLpMH)WD8<`k_C+zQRMW7kM6^qsa^_tA zrQK^)D04$_PRC1bc2};X4+p~l0d@$3NELEk=dsj}BF@-6ipoS}OQDs`+oEfpR7E(C z{=FPe=P$}yC-Pp|wtlnng8Fucq(f)zZ zx*X04@x(4wiWYiZ9H2|+<=UvHx?HI0MJx(M801!pVlFBj_)d)dT06pZ{_hrd9OT*7 zl~j*9JexM%ZbB_wfb;O*#E8&FhqnmH4)?I%@U-FFDCFdM$ZEz&jP0vW9DOureV(00 UY~h&qaLNZ5;DnKI$}_^*9}Y)V@c;k- diff --git a/target/classes/sf/codingcompetition2020/structures/Customer.class b/target/classes/sf/codingcompetition2020/structures/Customer.class deleted file mode 100644 index 844ea29474f5bc9dd328dee078d97b0567ad1de8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 806 zcma)4$!^;)5PkF-D|Vd5-S;%r9cj z!U!9l6xQinm@Zljn^%0v!;GsmJeypJ#4!YkPZ&=b*qEU=lg7GJo(qPp=x;&n40SqW zSj%`FZ}OC~THFZE&?TT;NwZ#ApShy~B8?e_3nO!GRuQ!>s-j>j7D7#_!qQxS`V>xP zVI-}iF1=W$ikCYuy#FtJ6kTWY4|RjXW8w?ubcJ)B$z(+%eIW-goUR=MLxTuoYdmt= z@$8dUZl0~qjmTw@Gix5^Q+{hApXUokcU2E@J>(>uo z?jGyHB;uninFn=XuY6l zd?VtyiCdL@+v_`C-}U+TeEoeqpgek(@){%`6ACK~wBLNgldl!cHpvdTfdJ1)_A9%M O9qbZfcuul`7ry~KU%=}C diff --git a/target/classes/sf/codingcompetition2020/structures/Dependent.class b/target/classes/sf/codingcompetition2020/structures/Dependent.class deleted file mode 100644 index 3ee505f7dda4d5aad7c64d98dd9748ea80a0698b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 384 zcmb7A%TB{E5F9sY(uUBM@&()g30!&waRG6P%Au%tCvl6b#I78N|Kfzife+xL5F7J4 zBTGBGJEPI8-#=d809@cOMvvjFS@Xh_N^c5N@1#>s89krPXS{K?EnI75!*AtI>QZVK zBV?Ft#gpKb&>McAZ)M>ahHGUTw-B{tm}YZ1I6hf1gg2&? z2?C@k1{gAoGo|ICt#fG~L|%DEQ;2FMtm@|PW#}GN!@#qD9Y9f%rD<&;?^I_!`aSKu zON}E?F8ZDxy*?t}#U2?kl#gmcTTaLb`=>A1d-k$@s*zs?7*U^o2{6WlCWZsAntlR( CuUa4g diff --git a/target/classes/sf/codingcompetition2020/structures/Vendor.class b/target/classes/sf/codingcompetition2020/structures/Vendor.class deleted file mode 100644 index fdbca9b6e0183e880547b8ff174552c31967ec4f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 419 zcma)&&rSj{5XQe*78YR@#D8aRN{owKHC{|iNH&^?;oz-wE0#b@x?SGOlZgi(z=tx< zE+k&Pe4XEPW;$QLe?GqeT;U`_KSP&+%H@SHoFsTOMJ#)z>?=%m`HhhjNZ?paJ1+|^616pM*)y5wy#^lv&R zT%`YZ#+$Xqws2D2>vC>;WB9UkfK%{B{9_>k)Y0H5K!j#>?rgb*HZ$8OH)Y*pN-75G e{SS2BtMYx;2B*OTd#rI4*KvSDCc+VGfa70hyb_Eo87v*2~*U; zK~esVxqkafPc6 z!yaXs8_u+*^IM8jVo2m0duAPr;Lp>htZCSeVmJjwuka{383t`j&6E|*$XMJqE0)Ub z%#`9N0?E#}p!Tq8S4mmb6|Edth(damvb*0`?olhYW0twq(C=nQ?`S+w@gd?>ZWPTX zfCNKoM*vU3SMPMslGkh}iav%;mz^i}Gf06kZ)Pt;uNM^0{RQEEh7$zM351F+;tAcFpNXO;FyH{IKa@I*9?B6QeNcNoU*8MkvgWT=mo{ngzQhYIVH_z z7`$YdN!0A$Mh5wFpSFyOF|| zEz7i`_<-T>c|&BXUgbquRE(y(Ao7}J5^C9=kYk;5B`%k_Q!n>H>qd8YnoY^(5 ztmdg@Rj3f7m}mIwwIk_bz9Jm%o~_~d9~2pms3I^yOzmmQEN3-m-J!$J+uWrP#U~7R zcRsgB;K2(Q2W4}OTZ%(DN=Zw#A}hLXKJ?SpYt^#Ot6Y~CIW5Se!)Ia)L*)88g&FQp zXXnLf(^}w)WnWsqrK{^%({?6pHHv$T{kSuikZKCRUlE32+tx_9JZ>({a;vJTJ6Gg( z5OdTw^y{YKl=Ssm7B6d+^3DYsRM{K#h3#16m0dKI?Udj62nLtgP$=sL@YtL}UkRPYFj3~{&H)>kAfVVN#1TYE%z0^MLa z>Lz5n;NHUa9nC3S(ddSqq4sMmiwdWPlrv^kO51==R}^$>dTnW3P%|WyU^1Kyq4siH zx|@56Zh+hp45TP3fr(Re6Ye_w#{z_ILF|!)FYy&MU(%m9ikhwJrp=2}79G)|c6U64 zaBh2g@uqg2EBbyiRs)l*!sNFS9^*TPfiP&{?StYhn_7x+x_jLaqu8wbS`+Unh6AB* z#bFUq9Hz^@mF|cr65_EzQiP-ySEeUNUGAcFdU(|3ILY+}1VqXm>(l0Q)@EjvGjQ&L0EjUHrG(DPtZnUA7MuKl229P9M{WwCS6fqhm z4(DjkY1%1ymNAa^Nn$udJ6mv;#)9`b`WFmO`wU|*FtL!h@EjNapjpqN*asYHLW|YW zCPUHgkk^IIu_P{~f5vDcnwZ+a^wVFEOX8+KbK9S394+n!ZIBL?!ch!089Y`uI2&qk zGyS;``Xfzf4f=&$pxp^UJ0FU+unV-iA!t`a(e8($O;O;5YX_2e;5stCfzN)$B7^X5 z!6Ivt3zbBu!;D`SJu06wI From 9a7cfa354c55007d7d3f10588a74e42643fbe593 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sat, 10 Oct 2020 22:27:10 -0400 Subject: [PATCH 07/26] fix merge error --- .../CodingCompCsvUtil.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index abe416b..1839d7e 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -2,16 +2,9 @@ import java.io.FileReader; import java.io.Reader; -<<<<<<< HEAD import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -======= -import java.lang.reflect.Array; import java.util.*; ->>>>>>> 4a61fb87fd49a14462182806e1412956997e44c9 +import java.lang.reflect.Array; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -21,7 +14,6 @@ import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -144,7 +136,7 @@ b. Whether that vendor is in scope of the insurance (if inScope == false, return * @return -- List of vendors within a given area, filtered by scope and vendor rating. */ public List getVendorsWithGivenRatingThatAreInScope(String filePath, String area, boolean inScope, int vendorRating) { - + return null; } @@ -157,7 +149,7 @@ public List getVendorsWithGivenRatingThatAreInScope(String filePath, Str * @param dependents -- The number of dependents on the insurance policy. * @return -- List of customers filtered by age, number of vehicles insured and the number of dependents. */ - public List getUndisclosedDrivers(String filePath, int vehiclesInsured, int dependents) { + public List getUndisclosedDrivers(String filePath, int vehiclesInsured, int dependents) throws IOException { List allCustomers = readCsvFile(filePath, Customer.class); List filteredCustomers = new ArrayList<>(); for (Customer current : allCustomers) { @@ -180,7 +172,7 @@ public List getUndisclosedDrivers(String filePath, int vehiclesInsured * @param agentRank -- The rank of the agent being requested. * @return -- Agent ID of agent with the given rank. */ - public int getAgentIdGivenRank(String filePath, int agentRank) { + public int getAgentIdGivenRank(String filePath, int agentRank) throws IOException { List allCustomers = readCsvFile(filePath, Customer.class); int numberOfAgents = Integer.MIN_VALUE; for (Customer currentCustomer : allCustomers) { @@ -228,7 +220,7 @@ public int getAgentIdGivenRank(String filePath, int agentRank) { * @param monthsOpen -- Number of months a policy has been open. * @return -- List of customers who’ve filed a claim within the last . */ - public List getCustomersWithClaims(Map csvFilePaths, short monthsOpen) { + public List getCustomersWithClaims(Map csvFilePaths, short monthsOpen) throws IOException { String customerListFilePath = csvFilePaths.get("customerList"); String claimsListFilePath = csvFilePaths.get("claimList"); List allCustomers = readCsvFile(customerListFilePath, Customer.class); From dfbf15b6efeb43563e99475ba3f765949f78e335 Mon Sep 17 00:00:00 2001 From: mniverthi Date: Sat, 10 Oct 2020 22:29:27 -0400 Subject: [PATCH 08/26] renamed to has and finished 6 --- .../java/sf/codingcompetition2020/CodingCompCsvUtil.java | 9 ++++++++- .../sf/codingcompetition2020/structures/Customer.java | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 811378e..430b27d 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -108,7 +108,14 @@ public List getCustomersRetainedForYearsByPlcyCostAsc(String customerF * @return -- List of customers who’ve made an inquiry for a policy but have not signed up. */ public List getLeadsForInsurance(String filePath) { - + List allCustomers = readCsvFile(filePath, Customer.class); + List customersWithoutPolicy = new ArrayList<>(); + for (Customer current : allCustomers) { + if (!current.hasAutoPolicy() && !current.hasHomePolicy() && !current.hasRentersPolicy()) { + customersWithoutPolicy.add(current); + } + } + return customersWithoutPolicy; } diff --git a/src/main/java/sf/codingcompetition2020/structures/Customer.java b/src/main/java/sf/codingcompetition2020/structures/Customer.java index 7b44af9..ba07303 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Customer.java +++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java @@ -216,7 +216,7 @@ public void setDependents(List dependents) { * Returns value of homePolicy * @return */ - public boolean isHomePolicy() { + public boolean hasHomePolicy() { return homePolicy; } @@ -232,7 +232,7 @@ public void setHomePolicy(boolean homePolicy) { * Returns value of autoPolicy * @return */ - public boolean isAutoPolicy() { + public boolean hasAutoPolicy() { return autoPolicy; } @@ -248,7 +248,7 @@ public void setAutoPolicy(boolean autoPolicy) { * Returns value of rentersPolicy * @return */ - public boolean isRentersPolicy() { + public boolean hasRentersPolicy() { return rentersPolicy; } From 2b4826a8cd516effde0a4f34e4796c455d293801 Mon Sep 17 00:00:00 2001 From: mniverthi Date: Sat, 10 Oct 2020 22:35:31 -0400 Subject: [PATCH 09/26] updated constructor --- .../CodingCompCsvUtil.java | 6 ++++++ .../structures/Customer.java | 18 +++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 430b27d..e95baf9 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -97,7 +97,13 @@ public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, * @return -- List of customers retained for a given number of years, in ascending order of policy cost. */ public List getCustomersRetainedForYearsByPlcyCostAsc(String customerFilePath, short yearsOfService) { + List allCustomers = readCsvFile(customerFilePath, Customer.class); + List retainedCustomers = new ArrayList<>(); + for (Customer current : ) + Collections.sort(retainedCustomers, (o1, o2) -> { + }); + return retainedCustomers; } diff --git a/src/main/java/sf/codingcompetition2020/structures/Customer.java b/src/main/java/sf/codingcompetition2020/structures/Customer.java index ba07303..1c3e29f 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Customer.java +++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java @@ -20,7 +20,7 @@ public class Customer { private boolean homePolicy; private boolean autoPolicy; private boolean rentersPolicy; - private String totalMonthlyPremium; + private int totalMonthlyPremium; private short yearsOfService; private Integer vehiclesInsured; @@ -40,7 +40,7 @@ public Customer(int customerId, String firstName, String lastName, int age, Stri this.homePolicy = homePolicy; this.autoPolicy = autoPolicy; this.rentersPolicy = rentersPolicy; - this.totalMonthlyPremium = totalMonthlyPremium; + this.totalMonthlyPremium = Integer.parseInt(totalMonthlyPremium.substring(1)); this.yearsOfService = yearsOfService; this.vehiclesInsured = vehiclesInsured; } @@ -264,7 +264,7 @@ public void setRentersPolicy(boolean rentersPolicy) { * Returns value of totalMonthlyPremium * @return */ - public String getTotalMonthlyPremium() { + public int getTotalMonthlyPremium() { return totalMonthlyPremium; } @@ -273,7 +273,7 @@ public String getTotalMonthlyPremium() { * @param */ public void setTotalMonthlyPremium(String totalMonthlyPremium) { - this.totalMonthlyPremium = totalMonthlyPremium; + this.totalMonthlyPremium = Integer.parseInt(totalMonthlyPremium.substring(1)); } /** @@ -321,18 +321,14 @@ public static class Builder { private boolean homePolicy; private boolean autoPolicy; private boolean rentersPolicy; - private String totalMonthlyPremium; + private int totalMonthlyPremium; private short yearsOfService; private Integer vehiclesInsured; public static Builder newBuilder() { return new Builder(); } - - - public static Builder newBuilder() { - return new Builder(); - } + public Builder customerId(int customerId) { this.customerId = customerId; return this; @@ -394,7 +390,7 @@ public Builder rentersPolicy(boolean rentersPolicy) { } public Builder totalMonthlyPremium(String totalMonthlyPremium) { - this.totalMonthlyPremium = totalMonthlyPremium; + this.totalMonthlyPremium = Integer.parseInt(totalMonthlyPremium.substring(1)); return this; } From 6f9d7ca60f0cce6cac8b3cfee01df090e6b1556c Mon Sep 17 00:00:00 2001 From: mniverthi Date: Sat, 10 Oct 2020 22:38:46 -0400 Subject: [PATCH 10/26] finished 5 --- .../sf/codingcompetition2020/CodingCompCsvUtil.java | 12 +++++++----- .../codingcompetition2020/structures/Customer.java | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index e95baf9..3f4181e 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -99,10 +99,12 @@ public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, public List getCustomersRetainedForYearsByPlcyCostAsc(String customerFilePath, short yearsOfService) { List allCustomers = readCsvFile(customerFilePath, Customer.class); List retainedCustomers = new ArrayList<>(); - for (Customer current : ) - Collections.sort(retainedCustomers, (o1, o2) -> { - - }); + for (Customer current : allCustomers) { + if (current.getYearsOfService() >= yearsOfService) { + retainedCustomers.add(current); + } + } + Collections.sort(retainedCustomers, Comparator.comparingInt(Customer::getTotalMonthlyPremium)); return retainedCustomers; } @@ -217,7 +219,7 @@ public int getAgentIdGivenRank(String filePath, int agentRank) { Collections.sort(agentAverageRatings, (o1, o2) -> { if (o1.getValue2() > o2.getValue2()) { return 1; - } else if (o1.getValue2() > o2.getValue2()) { + } else if (o1.getValue2() < o2.getValue2()) { return -1; } return 0; diff --git a/src/main/java/sf/codingcompetition2020/structures/Customer.java b/src/main/java/sf/codingcompetition2020/structures/Customer.java index 1c3e29f..61c218f 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Customer.java +++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java @@ -328,7 +328,7 @@ public static class Builder { public static Builder newBuilder() { return new Builder(); } - + public Builder customerId(int customerId) { this.customerId = customerId; return this; From b3eefcc8b44396103bbfc056595334f13fb38969 Mon Sep 17 00:00:00 2001 From: mniverthi Date: Sat, 10 Oct 2020 22:48:56 -0400 Subject: [PATCH 11/26] added custom 1 --- .../CodingCompCsvUtil.java | 22 +++++++++++++++++++ .../CodingCompCsvUtilTest.java | 1 - 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 3f4181e..0c52952 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -248,4 +248,26 @@ public List getCustomersWithClaims(Map csvFilePaths, s } return customersWithClaims; } + + /* Custom methods: 1 + * getCustomersWithClaims() -- Return a list of customers who have policies (inclusive). + * @param filePath -- Path to file being read in. + * @param numberOfPolicies -- Number of months a policy has been open. + * @return -- List of customers who have policies. + */ + public List getCustomersBasedOnNumberOfPolicies(String filePath, int numberOfPolicies) { + return readCsvFile(filePath, Customer.class).stream().filter(customer -> { + int policyCount = 0; + if (customer.hasAutoPolicy()) { + policyCount++; + } + if (customer.hasHomePolicy()) { + policyCount++; + } + if (customer.hasRentersPolicy()) { + policyCount++; + } + return policyCount == numberOfPolicies; + }).collect(Collectors.toList()); + } } diff --git a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java index c29959f..4d72ce6 100644 --- a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java +++ b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java @@ -119,6 +119,5 @@ public void getCountCustomersWithClaims() { assertEquals(81,codingCompCsVUtil.getCustomersWithClaims(csvFilePaths, Short.valueOf("1")).size()); assertEquals(312,codingCompCsVUtil.getCustomersWithClaims(csvFilePaths, Short.valueOf("6")).size()); } - } From 707015c8a6bd1e52e96545a1ebcd67c0853533b4 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sat, 10 Oct 2020 22:52:29 -0400 Subject: [PATCH 12/26] complete #2-#4 --- feedback.txt | 3 ++- .../codingcompetition2020/CodingCompCsvUtil.java | 13 +++++++------ .../CodingCompCsvUtilTest.java | 15 ++++++++------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/feedback.txt b/feedback.txt index fcc031d..56bcb84 100644 --- a/feedback.txt +++ b/feedback.txt @@ -7,7 +7,8 @@ Document and describe any enhancements included to help the judges properly grad If a file is not found, is does not make sense to just return an empty list, as we should instead tell the user that they are attempting to read a non-present file. We also changed some of the tests to throw the IOException. Step 3: We noticed that the vehiclesInsured field was unnecessarily declared as an Integer in the Customer class, so we converted it to an int. - Step 4: + Step 4: The Customer class was using a String for the totalMonthlyPremium because of a dollar sign, so we converted it to an int. + This makes future use of the value much more intuitive and meaningful. Feedback for the coding competition? Things you would like to see in future events? diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 1839d7e..6a08434 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -73,8 +73,8 @@ public List readCsvFile(String filePath, Class classType) throws IOExc * @param area -- The area from which the agents should be counted. * @return -- The number of agents in a given area */ - public int getAgentCountInArea(String filePath, String area) { - return -1; + public int getAgentCountInArea(String filePath, String area) throws IOException { + return (int) readCsvFile(filePath, Agent.class).stream().filter(agent -> agent.getArea().equals(area)).count(); } @@ -85,8 +85,8 @@ public int getAgentCountInArea(String filePath, String area) { * @param language -- The language spoken by the agent(s). * @return -- The number of agents in a given area */ - public List getAgentsInAreaThatSpeakLanguage(String filePath, String area, String language) { - return null; + public List getAgentsInAreaThatSpeakLanguage(String filePath, String area, String language) throws IOException { + return readCsvFile(filePath, Agent.class).stream().filter(agent -> agent.getArea().equals(area) && agent.getLanguage().equals(language)).collect(Collectors.toList()); } @@ -98,8 +98,9 @@ public List getAgentsInAreaThatSpeakLanguage(String filePath, String area * @param agentLastName -- Last name of agent. * @return -- The number of customers that use a certain agent in a given area. */ - public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, String customerArea, String agentFirstName, String agentLastName) { - return -1; + public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, String customerArea, String agentFirstName, String agentLastName) throws IOException { + Agent desiredAgent = (Agent) readCsvFile(csvFilePaths.get("agentList"), Agent.class).stream().filter(agent -> agent.getFirstName().equals(agentFirstName) && agent.getLanguage().equals(agentLastName)).toArray()[0]; + return (short) readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream().filter(customer -> customer.getArea().equals(customerArea) && customer.getAgentId() == desiredAgent.getAgentId()).count(); } diff --git a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java index c29959f..cd71eaf 100644 --- a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java +++ b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java @@ -2,6 +2,7 @@ import static org.junit.Assert.assertEquals; +import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -27,7 +28,7 @@ public class CodingCompCsvUtilTest{ //#1 @Test - public void test1() { + public void test1() throws IOException { assertEquals("Giacopo",((Agent)codingCompCsVUtil.readCsvFile(agentFilePath, Agent.class).get(1)).getFirstName()); assertEquals(424, ((Claim)codingCompCsVUtil.readCsvFile(claimFilePath, Claim.class).get(423)).getClaimId()); assertEquals("Lorin", ((Customer)codingCompCsVUtil.readCsvFile(customerFilePath, Customer.class).get(499)).getFirstName()); @@ -35,14 +36,14 @@ public void test1() { //#2 @Test - public void getAgentCountInArea() { + public void getAgentCountInArea() throws IOException { assertEquals(247,codingCompCsVUtil.getAgentCountInArea(agentFilePath, "area-4")); assertEquals(55,codingCompCsVUtil.getAgentCountInArea(agentFilePath, "area-2")); } //#3 @Test - public void getAgentsInAreaThatSpeakLanguage() { + public void getAgentsInAreaThatSpeakLanguage() throws IOException { List agentList = codingCompCsVUtil.getAgentsInAreaThatSpeakLanguage(agentFilePath, "area-3", "English"); assertEquals(2, agentList.size()); assertEquals(49, agentList.get(0).getAgentId()); @@ -55,7 +56,7 @@ public void getAgentsInAreaThatSpeakLanguage() { //#4 @Test - public void countCustomersFromCitythatUseAgent() { + public void countCustomersFromCitythatUseAgent() throws IOException { Map csvFilePaths = new HashMap<>(); csvFilePaths.put(agentList, agentFilePath); @@ -95,14 +96,14 @@ public void getVendorsWithGivenRatingThatAreInScope() { //#8 @Test - public void getCustomersRetainedForYearsByPlcyCostAsc2() { + public void getCustomersRetainedForYearsByPlcyCostAsc2() throws IOException { assertEquals(15,codingCompCsVUtil.getUndisclosedDrivers(customerFilePath,2,2).size()); assertEquals(14,codingCompCsVUtil.getUndisclosedDrivers(customerFilePath,3,3).size()); } //#9 @Test - public void getAgentIdGivenRank() { + public void getAgentIdGivenRank() throws IOException { assertEquals(3,codingCompCsVUtil.getAgentIdGivenRank(customerFilePath, 1)); assertEquals(12,codingCompCsVUtil.getAgentIdGivenRank(customerFilePath, 4)); assertEquals(14,codingCompCsVUtil.getAgentIdGivenRank(customerFilePath, 20)); @@ -110,7 +111,7 @@ public void getAgentIdGivenRank() { //#10 @Test - public void getCountCustomersWithClaims() { + public void getCountCustomersWithClaims() throws IOException { Map csvFilePaths = new HashMap<>(); csvFilePaths.put(customerList, customerFilePath); From 96daa6719e14fc66047e745176ae03080a7be5a9 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sat, 10 Oct 2020 22:55:41 -0400 Subject: [PATCH 13/26] some clinflicts --- .../java/sf/codingcompetition2020/CodingCompCsvUtil.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 6f8572c..012db23 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -110,7 +110,7 @@ public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, * @param yearsOfServeice -- Number of years the person has been a customer. * @return -- List of customers retained for a given number of years, in ascending order of policy cost. */ - public List getCustomersRetainedForYearsByPlcyCostAsc(String customerFilePath, short yearsOfService) { + public List getCustomersRetainedForYearsByPlcyCostAsc(String customerFilePath, short yearsOfService) throws IOException { List allCustomers = readCsvFile(customerFilePath, Customer.class); List retainedCustomers = new ArrayList<>(); for (Customer current : allCustomers) { @@ -129,7 +129,7 @@ public List getCustomersRetainedForYearsByPlcyCostAsc(String customerF * @param filePath -- Path to file being read in. * @return -- List of customers who’ve made an inquiry for a policy but have not signed up. */ - public List getLeadsForInsurance(String filePath) { + public List getLeadsForInsurance(String filePath) throws IOException { List allCustomers = readCsvFile(filePath, Customer.class); List customersWithoutPolicy = new ArrayList<>(); for (Customer current : allCustomers) { @@ -151,7 +151,7 @@ b. Whether that vendor is in scope of the insurance (if inScope == false, return * @param vendorRating -- The rating of the vendor. * @return -- List of vendors within a given area, filtered by scope and vendor rating. */ - public List getVendorsWithGivenRatingThatAreInScope(String filePath, String area, boolean inScope, int vendorRating) { + public List getVendorsWithGivenRatingThatAreInScope(String filePath, String area, boolean inScope, int vendorRating) throws IOException { List allVendors = readCsvFile(filePath, Vendor.class); List narrowedVendors = new ArrayList<>(); for (Vendor current : allVendors) { From 4e46009034dfdc25b05ecbd4cab31278415f317f Mon Sep 17 00:00:00 2001 From: mniverthi Date: Sat, 10 Oct 2020 22:57:44 -0400 Subject: [PATCH 14/26] added custom 2 --- .../CodingCompCsvUtil.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 0c52952..58ad3d8 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -250,7 +250,7 @@ public List getCustomersWithClaims(Map csvFilePaths, s } /* Custom methods: 1 - * getCustomersWithClaims() -- Return a list of customers who have policies (inclusive). + * getCustomersBasedOnNumberOfPolicies() -- Return a list of customers who have policies (inclusive). * @param filePath -- Path to file being read in. * @param numberOfPolicies -- Number of months a policy has been open. * @return -- List of customers who have policies. @@ -270,4 +270,32 @@ public List getCustomersBasedOnNumberOfPolicies(String filePath, int n return policyCount == numberOfPolicies; }).collect(Collectors.toList()); } + + /* Custom methods: 2 + * getVendorsForCustomerBasedOnArea() -- Return a list of vendors that operate in the area of a given customer. + * @param csvFilePaths -- Paths to files being read in. + * @param firstName -- last name of customer + * @param lastName -- first name of customer + * @return -- list of vendors that operate in the area of a given customer + */ + public List getVendorsForCustomerBasedOnArea(Map csvFilePaths, String firstName, String lastName) { + String customerListFilePath = csvFilePaths.get("customerList"); + String vendorListFilePath = csvFilePaths.get("vendorFilePath"); + List allCustomers = readCsvFile(customerListFilePath, Customer.class); + List allVendors = readCsvFile(vendorListFilePath, Vendor.class); + String desiredArea = ""; + List vendorsInArea = new ArrayList<>(); + for (Customer current : allCustomers) { + if (current.getFirstName().equals(firstName) && current.getLastName().equals(lastName)) { + desiredArea = current.getArea(); + break; + } + } + for (Vendor current : allVendors) { + if (current.getArea().equals(desiredArea)) { + vendorsInArea.add(current); + } + } + return vendorsInArea; + } } From 311d22e3ce71c4ec2150b00f83280a8dfe06747e Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sat, 10 Oct 2020 23:43:01 -0400 Subject: [PATCH 15/26] use stream --- .../CodingCompCsvUtil.java | 112 ++++++------------ .../CodingCompCsvUtilTest.java | 2 +- 2 files changed, 38 insertions(+), 76 deletions(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 012db23..acdf15d 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -111,15 +111,7 @@ public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, * @return -- List of customers retained for a given number of years, in ascending order of policy cost. */ public List getCustomersRetainedForYearsByPlcyCostAsc(String customerFilePath, short yearsOfService) throws IOException { - List allCustomers = readCsvFile(customerFilePath, Customer.class); - List retainedCustomers = new ArrayList<>(); - for (Customer current : allCustomers) { - if (current.getYearsOfService() >= yearsOfService) { - retainedCustomers.add(current); - } - } - Collections.sort(retainedCustomers, Comparator.comparingInt(Customer::getTotalMonthlyPremium)); - return retainedCustomers; + return readCsvFile(customerFilePath, Customer.class).stream().filter(customer -> customer.getYearsOfService() >= yearsOfService).sorted(Comparator.comparingInt(Customer::getTotalMonthlyPremium)).collect(Collectors.toList()); } @@ -130,14 +122,7 @@ public List getCustomersRetainedForYearsByPlcyCostAsc(String customerF * @return -- List of customers who’ve made an inquiry for a policy but have not signed up. */ public List getLeadsForInsurance(String filePath) throws IOException { - List allCustomers = readCsvFile(filePath, Customer.class); - List customersWithoutPolicy = new ArrayList<>(); - for (Customer current : allCustomers) { - if (!current.hasAutoPolicy() && !current.hasHomePolicy() && !current.hasRentersPolicy()) { - customersWithoutPolicy.add(current); - } - } - return customersWithoutPolicy; + return readCsvFile(filePath, Customer.class).stream().filter(customer -> !customer.hasAutoPolicy() && !customer.hasHomePolicy() && !customer.hasRentersPolicy()).collect(Collectors.toList()); } @@ -152,20 +137,7 @@ b. Whether that vendor is in scope of the insurance (if inScope == false, return * @return -- List of vendors within a given area, filtered by scope and vendor rating. */ public List getVendorsWithGivenRatingThatAreInScope(String filePath, String area, boolean inScope, int vendorRating) throws IOException { - List allVendors = readCsvFile(filePath, Vendor.class); - List narrowedVendors = new ArrayList<>(); - for (Vendor current : allVendors) { - if (current.getVendorRating() == vendorRating && area.equals(current.getArea())) { - if (inScope) { - if (current.isInScope()) { - narrowedVendors.add(current); - } - } else { - narrowedVendors.add(current); - } - } - } - return narrowedVendors; + return readCsvFile(filePath, Vendor.class).stream().filter(vendor -> vendor.getVendorRating() == vendorRating && vendor.getArea().equals(area) && (!inScope || vendor.isInScope())).collect(Collectors.toList()); } @@ -179,16 +151,7 @@ public List getVendorsWithGivenRatingThatAreInScope(String filePath, Str * @return -- List of customers filtered by age, number of vehicles insured and the number of dependents. */ public List getUndisclosedDrivers(String filePath, int vehiclesInsured, int dependents) throws IOException { - List allCustomers = readCsvFile(filePath, Customer.class); - List filteredCustomers = new ArrayList<>(); - for (Customer current : allCustomers) { - if (current.getAge() >= 40 && current.getAge() <= 50) { - if (current.getVehiclesInsured() > vehiclesInsured && current.getDependents().size() <= dependents) { - filteredCustomers.add(current); - } - } - } - return filteredCustomers; + return readCsvFile(filePath, Customer.class).stream().filter(customer -> customer.getAge() >= 40 && customer.getAge() <= 50 && customer.getVehiclesInsured() > vehiclesInsured && customer.getDependents().size() <= dependents).collect(Collectors.toList()); } @@ -206,39 +169,48 @@ public int getAgentIdGivenRank(String filePath, int agentRank) throws IOExceptio for (Customer currentCustomer : allCustomers) { numberOfAgents = Math.min(numberOfAgents, currentCustomer.getAgentId()); } - Map> agentRatingsList = new HashMap<>(); + Map> agentRatingsMap = new HashMap<>(); for (Customer currentCustomer : allCustomers) { int currentAgentId = currentCustomer.getAgentId(); int currentAgentRating = currentCustomer.getAgentRating(); - if (agentRatingsList.containsKey(currentAgentId)) { - List currentAgentList = agentRatingsList.get(currentAgentId); + if (agentRatingsMap.containsKey(currentAgentId)) { + List currentAgentList = agentRatingsMap.get(currentAgentId); currentAgentList.set(0, currentAgentList.get(0) + 1); currentAgentList.set(1, currentAgentList.get(1) + currentAgentRating); - agentRatingsList.put(currentAgentId, currentAgentList); + agentRatingsMap.put(currentAgentId, currentAgentList); } else { List newAgentList = new ArrayList<>(); newAgentList.add(1); newAgentList.add(currentAgentRating); - agentRatingsList.put(currentAgentId, newAgentList); + agentRatingsMap.put(currentAgentId, newAgentList); } } - List> agentAverageRatings = new ArrayList<>(); - for (Map.Entry> entry : agentRatingsList.entrySet()) { - Integer agentId = entry.getKey(); - Integer numReviews = entry.getValue().get(0); - Integer totalRating = entry.getValue().get(1); - Double averageRating = (double)(totalRating) / numReviews; - agentAverageRatings.add(new Pair<>(agentId, averageRating)); - } - Collections.sort(agentAverageRatings, (o1, o2) -> { - if (o1.getValue2() > o2.getValue2()) { - return 1; - } else if (o1.getValue2() < o2.getValue2()) { - return -1; - } - return 0; - }); - return agentAverageRatings.get(agentRank - 1).getValue1(); + return ((Pair) agentRatingsMap.entrySet().stream().map(entry -> new Pair(entry.getKey(), entry.getValue().stream().mapToInt(rating -> rating).summaryStatistics().getAverage())).sorted((agent1, agent2) -> { + if (agent1.getValue2() > agent2.getValue2()) { + return 1; + } else if (agent1.getValue2() < agent2.getValue2()) { + return -1; + } + return 0; + }).skip(agentRank-1).limit(1).toArray()[0]).getValue1(); +// +// List> agentAverageRatings = new ArrayList<>(); +// for (Map.Entry> entry : agentRatingsMap.entrySet()) { +// Integer agentId = entry.getKey(); +// Integer numReviews = entry.getValue().get(0); +// Integer totalRating = entry.getValue().get(1); +// Double averageRating = (double)(totalRating) / numReviews; +// agentAverageRatings.add(new Pair<>(agentId, averageRating)); +// } +// Collections.sort(entryList, (o1, o2) -> { +// if (o1.getValue2() > o2.getValue2()) { +// return 1; +// } else if (o1.getValue2() < o2.getValue2()) { +// return -1; +// } +// return 0; +// }); +// return agentAverageRatings.get(agentRank - 1).getValue1(); } @@ -249,17 +221,7 @@ public int getAgentIdGivenRank(String filePath, int agentRank) throws IOExceptio * @return -- List of customers who’ve filed a claim within the last . */ public List getCustomersWithClaims(Map csvFilePaths, short monthsOpen) throws IOException { - String customerListFilePath = csvFilePaths.get("customerList"); - String claimsListFilePath = csvFilePaths.get("claimList"); - List allCustomers = readCsvFile(customerListFilePath, Customer.class); - List allClaims = readCsvFile(claimsListFilePath, Claim.class); - List customersWithClaims = new ArrayList<>(); - for (Claim currentClaim : allClaims) { - if (currentClaim.getMonthsOpen() <= monthsOpen) { - int currentClaimCustomerId = currentClaim.getCustomerId(); - customersWithClaims.add(allCustomers.get(currentClaimCustomerId)); - } - } - return customersWithClaims; + List customerIDsWithRecentClaim = readCsvFile(csvFilePaths.get("claimList"), Claim.class).stream().filter(claim -> claim.getMonthsOpen() <= monthsOpen).map(claim -> claim.getCustomerId()).collect(Collectors.toList()); + return readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream().filter(customer -> customerIDsWithRecentClaim.contains(customer.getCustomerId())).collect(Collectors.toList()); } } diff --git a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java index cd71eaf..bc4d19f 100644 --- a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java +++ b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java @@ -68,7 +68,7 @@ public void countCustomersFromCitythatUseAgent() throws IOException { //#5 @Test - public void getCustomersRetainedForYearsByPlcyCostAsc() { + public void getCustomersRetainedForYearsByPlcyCostAsc() throws IOException { List customerList = codingCompCsVUtil.getCustomersRetainedForYearsByPlcyCostAsc(customerFilePath, Short.valueOf("5")); assertEquals(15,customerList.size()); From 3722e046210e4285bfc7514a2c2ac7244dfac277 Mon Sep 17 00:00:00 2001 From: mniverthi Date: Sat, 10 Oct 2020 23:43:39 -0400 Subject: [PATCH 16/26] fixed csv parser thing --- .../CodingCompCsvUtil.java | 7 +++++-- .../structures/Customer.java | 11 +++++++---- .../structures/Dependent.java | 18 ++++++++++++++++++ .../structures/Vendor.java | 13 +++++++++++++ .../CodingCompCsvUtilTest.java | 6 +++--- 5 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 91e7e55..67923cd 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -44,6 +44,7 @@ public List readCsvFile(String filePath, Class classType) throws IOExc CsvMapper mapper = new CsvMapper(); mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY); MappingIterator it = mapper.readerFor(Object[].class).readValues(csvFile); + it.nextValue(); it.forEachRemaining(row -> { try { interpretedFile.add(classType.getConstructor(List.class).newInstance(Arrays.asList(row))); @@ -51,7 +52,9 @@ public List readCsvFile(String filePath, Class classType) throws IOExc e.printStackTrace(); } }); + if (classType.equals(Customer.class)) { + } // FileReader fr = new FileReader(csvFile); // BufferedReader br = new BufferedReader(fr); // String entry; @@ -269,7 +272,7 @@ public List getCustomersWithClaims(Map csvFilePaths, s * @param numberOfPolicies -- Number of months a policy has been open. * @return -- List of customers who have policies. */ - public List getCustomersBasedOnNumberOfPolicies(String filePath, int numberOfPolicies) { + public List getCustomersBasedOnNumberOfPolicies(String filePath, int numberOfPolicies) throws IOException { return readCsvFile(filePath, Customer.class).stream().filter(customer -> { int policyCount = 0; if (customer.hasAutoPolicy()) { @@ -292,7 +295,7 @@ public List getCustomersBasedOnNumberOfPolicies(String filePath, int n * @param lastName -- first name of customer * @return -- list of vendors that operate in the area of a given customer */ - public List getVendorsForCustomerBasedOnArea(Map csvFilePaths, String firstName, String lastName) { + public List getVendorsForCustomerBasedOnArea(Map csvFilePaths, String firstName, String lastName) throws IOException { String customerListFilePath = csvFilePaths.get("customerList"); String vendorListFilePath = csvFilePaths.get("vendorFilePath"); List allCustomers = readCsvFile(customerListFilePath, Customer.class); diff --git a/src/main/java/sf/codingcompetition2020/structures/Customer.java b/src/main/java/sf/codingcompetition2020/structures/Customer.java index e36d630..395952a 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Customer.java +++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java @@ -4,10 +4,13 @@ import java.util.List; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.DeserializationFeature; public class Customer { + private int customerId; private String firstName; private String lastName; @@ -49,7 +52,7 @@ public Customer(int customerId, String firstName, String lastName, int age, Stri * constructor based on an entry in a CSV * @param csvEntry */ - public Customer(List csvEntry) { + public Customer(List csvEntry) throws JsonProcessingException { this( Integer.parseInt(csvEntry.get(0)), csvEntry.get(1), @@ -59,7 +62,7 @@ public Customer(List csvEntry) { Integer.parseInt(csvEntry.get(5)), Short.parseShort(csvEntry.get(6)), csvEntry.get(7), - (List)(Object)csvEntry.get(8), + csvEntry.get(8).isEmpty() ? new ArrayList<>() : new ObjectMapper().readValue(csvEntry.get(8), new TypeReference>(){}), Boolean.parseBoolean(csvEntry.get(9)), Boolean.parseBoolean(csvEntry.get(10)), Boolean.parseBoolean(csvEntry.get(11)), @@ -345,7 +348,7 @@ public static class Builder { private boolean homePolicy; private boolean autoPolicy; private boolean rentersPolicy; - private int totalMonthlyPremium; + private String totalMonthlyPremium; private short yearsOfService; private int vehiclesInsured; @@ -414,7 +417,7 @@ public Builder rentersPolicy(boolean rentersPolicy) { } public Builder totalMonthlyPremium(String totalMonthlyPremium) { - this.totalMonthlyPremium = Integer.parseInt(totalMonthlyPremium.substring(1)); + this.totalMonthlyPremium = totalMonthlyPremium; return this; } diff --git a/src/main/java/sf/codingcompetition2020/structures/Dependent.java b/src/main/java/sf/codingcompetition2020/structures/Dependent.java index 90906c0..f47e604 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Dependent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Dependent.java @@ -1,9 +1,27 @@ package sf.codingcompetition2020.structures; +import java.util.List; + public class Dependent { private String firstName; private String lastName; + /** + * + */ + public Dependent() { + super(); + } + /** + * constructor based on an entry in a CSV + * @param csvEntry + */ + public Dependent(List csvEntry) { + this( + csvEntry.get(0), + csvEntry.get(1) + ); + } /** * Default Dependent constructor */ diff --git a/src/main/java/sf/codingcompetition2020/structures/Vendor.java b/src/main/java/sf/codingcompetition2020/structures/Vendor.java index d14c92e..e253927 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Vendor.java +++ b/src/main/java/sf/codingcompetition2020/structures/Vendor.java @@ -1,11 +1,24 @@ package sf.codingcompetition2020.structures; +import java.util.List; + public class Vendor { private int vendorId; private String area; private int vendorRating; private boolean inScope; + /** + * constructor based on an entry in a CSV + * @param csvEntry + */ + public Vendor(List csvEntry) { + this( + Integer.parseInt(csvEntry.get(0)), + csvEntry.get(1), + Integer.parseInt(csvEntry.get(2)), + Boolean.parseBoolean(csvEntry.get(3))); + } /** * Default Vendor constructor */ diff --git a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java index 042474f..d3b5acf 100644 --- a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java +++ b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java @@ -68,7 +68,7 @@ public void countCustomersFromCitythatUseAgent() throws IOException { //#5 @Test - public void getCustomersRetainedForYearsByPlcyCostAsc() { + public void getCustomersRetainedForYearsByPlcyCostAsc() throws IOException { List customerList = codingCompCsVUtil.getCustomersRetainedForYearsByPlcyCostAsc(customerFilePath, Short.valueOf("5")); assertEquals(15,customerList.size()); @@ -82,13 +82,13 @@ public void getCustomersRetainedForYearsByPlcyCostAsc() { //#6 @Test - public void getLeadsForInsurance() { + public void getLeadsForInsurance() throws IOException { assertEquals(82, codingCompCsVUtil.getLeadsForInsurance(customerFilePath).size()); } //#7 @Test - public void getVendorsWithGivenRatingThatAreInScope() { + public void getVendorsWithGivenRatingThatAreInScope() throws IOException { assertEquals(11, codingCompCsVUtil.getVendorsWithGivenRatingThatAreInScope(vendorFilePath, "area-5", true, 4).size()); assertEquals(2, codingCompCsVUtil.getVendorsWithGivenRatingThatAreInScope(vendorFilePath, "area-2", true, 2).size()); assertEquals(12, codingCompCsVUtil.getVendorsWithGivenRatingThatAreInScope(vendorFilePath, "area-3", false, 3).size()); From 52c12d32793718a8a950cf6d62a8210bb375d489 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 11 Oct 2020 00:12:12 -0400 Subject: [PATCH 17/26] fix tests --- feedback.txt | 4 ++- .../CodingCompCsvUtil.java | 14 +++++++-- .../structures/Agent.java | 11 +++++++ .../structures/Claim.java | 10 +++++++ .../structures/Customer.java | 21 ++++++++++++++ .../structures/Dependent.java | 8 +++++ .../structures/Vendor.java | 29 +++++++++++++------ .../codingcompetition2020/utilities/Pair.java | 14 +++++++-- .../CodingCompCsvUtilTest.java | 4 +-- 9 files changed, 97 insertions(+), 18 deletions(-) diff --git a/feedback.txt b/feedback.txt index 56bcb84..5a1adc6 100644 --- a/feedback.txt +++ b/feedback.txt @@ -1,5 +1,5 @@ Your team (name of each individual participating): Mudit Gupta, Manoj Niverthi -How many JUnits were you able to get to pass? +How many JUnits were you able to get to pass? 10 Document and describe any enhancements included to help the judges properly grade your submission. Step 1: We used Checkstyle to make sure the code was readable according to publicly agreed upon standards. @@ -9,6 +9,8 @@ Document and describe any enhancements included to help the judges properly grad Step 3: We noticed that the vehiclesInsured field was unnecessarily declared as an Integer in the Customer class, so we converted it to an int. Step 4: The Customer class was using a String for the totalMonthlyPremium because of a dollar sign, so we converted it to an int. This makes future use of the value much more intuitive and meaningful. + We also updated the test values in the JUnit to reflect the better implementation. + Step 5: Feedback for the coding competition? Things you would like to see in future events? diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index be3a047..6fdd6fe 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -102,7 +102,7 @@ public List getAgentsInAreaThatSpeakLanguage(String filePath, String area * @return -- The number of customers that use a certain agent in a given area. */ public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, String customerArea, String agentFirstName, String agentLastName) throws IOException { - Agent desiredAgent = (Agent) readCsvFile(csvFilePaths.get("agentList"), Agent.class).stream().filter(agent -> agent.getFirstName().equals(agentFirstName) && agent.getLanguage().equals(agentLastName)).toArray()[0]; + Agent desiredAgent = (Agent) readCsvFile(csvFilePaths.get("agentList"), Agent.class).stream().filter(agent -> agent.getFirstName().equals(agentFirstName) && agent.getLastName().equals(agentLastName)).toArray()[0]; return (short) readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream().filter(customer -> customer.getArea().equals(customerArea) && customer.getAgentId() == desiredAgent.getAgentId()).count(); } @@ -114,7 +114,7 @@ public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, * @return -- List of customers retained for a given number of years, in ascending order of policy cost. */ public List getCustomersRetainedForYearsByPlcyCostAsc(String customerFilePath, short yearsOfService) throws IOException { - return readCsvFile(customerFilePath, Customer.class).stream().filter(customer -> customer.getYearsOfService() >= yearsOfService).sorted(Comparator.comparingInt(Customer::getTotalMonthlyPremium)).collect(Collectors.toList()); + return readCsvFile(customerFilePath, Customer.class).stream().filter(customer -> customer.getYearsOfService() == yearsOfService).sorted(Comparator.comparingInt(Customer::getTotalMonthlyPremium)).collect(Collectors.toList()); } @@ -140,7 +140,7 @@ b. Whether that vendor is in scope of the insurance (if inScope == false, return * @return -- List of vendors within a given area, filtered by scope and vendor rating. */ public List getVendorsWithGivenRatingThatAreInScope(String filePath, String area, boolean inScope, int vendorRating) throws IOException { - return readCsvFile(filePath, Vendor.class).stream().filter(vendor -> vendor.getVendorRating() == vendorRating && vendor.getArea().equals(area) && (!inScope || vendor.isInScope())).collect(Collectors.toList()); + return readCsvFile(filePath, Vendor.class).stream().filter(vendor -> vendor.getArea().equals(area) && vendor.getVendorRating() >= vendorRating && (!inScope || vendor.isInScope())).collect(Collectors.toList()); } @@ -188,6 +188,14 @@ public int getAgentIdGivenRank(String filePath, int agentRank) throws IOExceptio agentRatingsMap.put(currentAgentId, newAgentList); } } + System.out.println(agentRatingsMap.entrySet().stream().map(entry -> new Pair(entry.getKey(), entry.getValue().stream().mapToInt(rating -> rating).summaryStatistics().getAverage())).sorted((agent1, agent2) -> { + if (agent1.getValue2() > agent2.getValue2()) { + return 1; + } else if (agent1.getValue2() < agent2.getValue2()) { + return -1; + } + return 0; + }).collect(Collectors.toList())); return ((Pair) agentRatingsMap.entrySet().stream().map(entry -> new Pair(entry.getKey(), entry.getValue().stream().mapToInt(rating -> rating).summaryStatistics().getAverage())).sorted((agent1, agent2) -> { if (agent1.getValue2() > agent2.getValue2()) { return 1; diff --git a/src/main/java/sf/codingcompetition2020/structures/Agent.java b/src/main/java/sf/codingcompetition2020/structures/Agent.java index f907ec0..6875f84 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Agent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Agent.java @@ -127,6 +127,17 @@ public void setLastName(String lastName) { this.lastName = lastName; } + @Override + public String toString() { + return "Agent{" + + "agentId=" + agentId + + ", area='" + area + '\'' + + ", language='" + language + '\'' + + ", firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + '}'; + } + public static class Builder { private int agentId; private String area; diff --git a/src/main/java/sf/codingcompetition2020/structures/Claim.java b/src/main/java/sf/codingcompetition2020/structures/Claim.java index d83d166..20aaccc 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Claim.java +++ b/src/main/java/sf/codingcompetition2020/structures/Claim.java @@ -107,6 +107,16 @@ public void setMonthsOpen(int monthsOpen) { this.monthsOpen = monthsOpen; } + @Override + public String toString() { + return "Claim{" + + "claimId=" + claimId + + ", customerId=" + customerId + + ", closed=" + closed + + ", monthsOpen=" + monthsOpen + + '}'; + } + public static class Builder { private int claimId; private int customerId; diff --git a/src/main/java/sf/codingcompetition2020/structures/Customer.java b/src/main/java/sf/codingcompetition2020/structures/Customer.java index 395952a..2f8c41b 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Customer.java +++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java @@ -335,6 +335,27 @@ public void setVehiclesInsured(int vehiclesInsured) { this.vehiclesInsured = vehiclesInsured; } + @Override + public String toString() { + return "Customer{" + + "customerId=" + customerId + + ", firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + ", age=" + age + + ", area='" + area + '\'' + + ", agentId=" + agentId + + ", agentRating=" + agentRating + + ", primaryLanguage='" + primaryLanguage + '\'' + + ", dependents=" + dependents + + ", homePolicy=" + homePolicy + + ", autoPolicy=" + autoPolicy + + ", rentersPolicy=" + rentersPolicy + + ", totalMonthlyPremium=" + totalMonthlyPremium + + ", yearsOfService=" + yearsOfService + + ", vehiclesInsured=" + vehiclesInsured + + '}'; + } + public static class Builder { private int customerId; private String firstName; diff --git a/src/main/java/sf/codingcompetition2020/structures/Dependent.java b/src/main/java/sf/codingcompetition2020/structures/Dependent.java index f47e604..cb34382 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Dependent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Dependent.java @@ -70,6 +70,14 @@ public void setLastName(String lastName) { this.lastName = lastName; } + @Override + public String toString() { + return "Dependent{" + + "firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + '}'; + } + public static class Builder { private String firstName; private String lastName; diff --git a/src/main/java/sf/codingcompetition2020/structures/Vendor.java b/src/main/java/sf/codingcompetition2020/structures/Vendor.java index e253927..81eb554 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Vendor.java +++ b/src/main/java/sf/codingcompetition2020/structures/Vendor.java @@ -8,6 +8,16 @@ public class Vendor { private int vendorRating; private boolean inScope; + /** + * Default Vendor constructor + */ + public Vendor(int vendorId, String area, int vendorRating, boolean inScope) { + this.vendorId = vendorId; + this.area = area; + this.vendorRating = vendorRating; + this.inScope = inScope; + } + /** * constructor based on an entry in a CSV * @param csvEntry @@ -19,15 +29,6 @@ public Vendor(List csvEntry) { Integer.parseInt(csvEntry.get(2)), Boolean.parseBoolean(csvEntry.get(3))); } - /** - * Default Vendor constructor - */ - public Vendor(int vendorId, String area, int vendorRating, boolean inScope) { - this.vendorId = vendorId; - this.area = area; - this.vendorRating = vendorRating; - this.inScope = inScope; - } /** * Builder constructor @@ -105,6 +106,16 @@ public void setInScope(boolean inScope) { this.inScope = inScope; } + @Override + public String toString() { + return "Vendor{" + + "vendorId=" + vendorId + + ", area='" + area + '\'' + + ", vendorRating=" + vendorRating + + ", inScope=" + inScope + + '}'; + } + public static class Builder { private int vendorId; private String area; diff --git a/src/main/java/sf/codingcompetition2020/utilities/Pair.java b/src/main/java/sf/codingcompetition2020/utilities/Pair.java index 20dc438..2c4610e 100644 --- a/src/main/java/sf/codingcompetition2020/utilities/Pair.java +++ b/src/main/java/sf/codingcompetition2020/utilities/Pair.java @@ -5,6 +5,11 @@ public class Pair { private T value1; private V value2; + public Pair(T value1, V value2) { + this.value1 = value1; + this.value2 = value2; + } + public T getValue1() { return value1; } @@ -21,8 +26,11 @@ public void setValue2(V value2) { this.value2 = value2; } - public Pair(T value1, V value2) { - this.value1 = value1; - this.value2 = value2; + @Override + public String toString() { + return "Pair{" + + "value1=" + value1 + + ", value2=" + value2 + + '}'; } } diff --git a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java index d3b5acf..ef73d80 100644 --- a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java +++ b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java @@ -74,10 +74,10 @@ public void getCustomersRetainedForYearsByPlcyCostAsc() throws IOException { assertEquals(15,customerList.size()); assertEquals(215,customerList.get(0).getCustomerId()); assertEquals(5,customerList.get(2).getYearsOfService()); - assertEquals("$388",customerList.get(3).getTotalMonthlyPremium()); + assertEquals(388,customerList.get(3).getTotalMonthlyPremium()); assertEquals("Janka",customerList.get(4).getFirstName()); assertEquals("Tesoe",customerList.get(5).getLastName()); - assertEquals("$888",customerList.get(14).getTotalMonthlyPremium()); + assertEquals(888,customerList.get(14).getTotalMonthlyPremium()); } //#6 From 7169cb34896b11dfb75a77cd5df4da047858d561 Mon Sep 17 00:00:00 2001 From: mniverthi Date: Sun, 11 Oct 2020 00:18:53 -0400 Subject: [PATCH 18/26] added tests --- .../CodingCompCsvUtil.java | 45 ++++++++----------- .../CodingCompCsvUtilTest.java | 20 ++++++++- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index be3a047..aee3e49 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -188,32 +188,23 @@ public int getAgentIdGivenRank(String filePath, int agentRank) throws IOExceptio agentRatingsMap.put(currentAgentId, newAgentList); } } - return ((Pair) agentRatingsMap.entrySet().stream().map(entry -> new Pair(entry.getKey(), entry.getValue().stream().mapToInt(rating -> rating).summaryStatistics().getAverage())).sorted((agent1, agent2) -> { - if (agent1.getValue2() > agent2.getValue2()) { - return 1; - } else if (agent1.getValue2() < agent2.getValue2()) { - return -1; - } - return 0; - }).skip(agentRank-1).limit(1).toArray()[0]).getValue1(); -// -// List> agentAverageRatings = new ArrayList<>(); -// for (Map.Entry> entry : agentRatingsMap.entrySet()) { -// Integer agentId = entry.getKey(); -// Integer numReviews = entry.getValue().get(0); -// Integer totalRating = entry.getValue().get(1); -// Double averageRating = (double)(totalRating) / numReviews; -// agentAverageRatings.add(new Pair<>(agentId, averageRating)); -// } -// Collections.sort(entryList, (o1, o2) -> { -// if (o1.getValue2() > o2.getValue2()) { -// return 1; -// } else if (o1.getValue2() < o2.getValue2()) { -// return -1; -// } -// return 0; -// }); -// return agentAverageRatings.get(agentRank - 1).getValue1(); + List> agentAverageRatings = new ArrayList<>(); + for (Map.Entry> entry : agentRatingsMap.entrySet()) { + Integer agentId = entry.getKey(); + Integer numReviews = entry.getValue().get(0); + Integer totalRating = entry.getValue().get(1); + Double averageRating = (double)(totalRating) / numReviews; + agentAverageRatings.add(new Pair<>(agentId, averageRating)); + } + Collections.sort(agentAverageRatings, (o1, o2) -> { + if (o1.getValue2() < o2.getValue2()) { + return 1; + } else if (o1.getValue2() > o2.getValue2()) { + return -1; + } + return 0; + }); + return agentAverageRatings.get(agentRank - 1).getValue1(); } @@ -259,7 +250,7 @@ public List getCustomersBasedOnNumberOfPolicies(String filePath, int n */ public List getVendorsForCustomerBasedOnArea(Map csvFilePaths, String firstName, String lastName) throws IOException { String customerListFilePath = csvFilePaths.get("customerList"); - String vendorListFilePath = csvFilePaths.get("vendorFilePath"); + String vendorListFilePath = csvFilePaths.get("vendorList"); List allCustomers = readCsvFile(customerListFilePath, Customer.class); List allVendors = readCsvFile(vendorListFilePath, Vendor.class); String desiredArea = ""; diff --git a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java index d3b5acf..ec11e21 100644 --- a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java +++ b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java @@ -22,6 +22,7 @@ public class CodingCompCsvUtilTest{ private final String agentList = "agentList"; private final String claimList = "claimList"; private final String customerList = "customerList"; + private final String vendorList = "vendorList"; CodingCompCsvUtil codingCompCsVUtil = new CodingCompCsvUtil(); @@ -119,6 +120,23 @@ public void getCountCustomersWithClaims() throws IOException { assertEquals(81,codingCompCsVUtil.getCustomersWithClaims(csvFilePaths, Short.valueOf("1")).size()); assertEquals(312,codingCompCsVUtil.getCustomersWithClaims(csvFilePaths, Short.valueOf("6")).size()); - } + } + + //#Custom 1 + @Test + public void getCustomersBasedOnNumberOfPolicies() throws IOException { + assertEquals(195, codingCompCsVUtil.getCustomersBasedOnNumberOfPolicies(customerFilePath, Integer.valueOf("1")).size()); + assertEquals(40, codingCompCsVUtil.getCustomersBasedOnNumberOfPolicies(customerFilePath, Integer.valueOf("3")).size()); + } + + @Test + public void getVendorsForCustomerBasedOnArea() throws IOException { + Map csvFilePaths = new HashMap<>(); + csvFilePaths.put(customerList, customerFilePath); + csvFilePaths.put(vendorList, vendorFilePath); + System.out.println(codingCompCsVUtil.getVendorsForCustomerBasedOnArea(csvFilePaths, "Alexine", "Spinella").toString()); + System.out.println(codingCompCsVUtil.getVendorsForCustomerBasedOnArea(csvFilePaths, "Brandon", "Dwerryhouse").toString()); + assertEquals(0, 1); + } } From ece9a120b9b79082bed70d49fe483eefdfb56b38 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 11 Oct 2020 00:19:00 -0400 Subject: [PATCH 19/26] use streams --- .../CodingCompCsvUtil.java | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 6fdd6fe..80fb5e7 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -261,28 +261,12 @@ public List getCustomersBasedOnNumberOfPolicies(String filePath, int n /* Custom methods: 2 * getVendorsForCustomerBasedOnArea() -- Return a list of vendors that operate in the area of a given customer. * @param csvFilePaths -- Paths to files being read in. - * @param firstName -- last name of customer - * @param lastName -- first name of customer + * @param customerFirstName -- last name of customer + * @param customerLastName -- first name of customer * @return -- list of vendors that operate in the area of a given customer */ - public List getVendorsForCustomerBasedOnArea(Map csvFilePaths, String firstName, String lastName) throws IOException { - String customerListFilePath = csvFilePaths.get("customerList"); - String vendorListFilePath = csvFilePaths.get("vendorFilePath"); - List allCustomers = readCsvFile(customerListFilePath, Customer.class); - List allVendors = readCsvFile(vendorListFilePath, Vendor.class); - String desiredArea = ""; - List vendorsInArea = new ArrayList<>(); - for (Customer current : allCustomers) { - if (current.getFirstName().equals(firstName) && current.getLastName().equals(lastName)) { - desiredArea = current.getArea(); - break; - } - } - for (Vendor current : allVendors) { - if (current.getArea().equals(desiredArea)) { - vendorsInArea.add(current); - } - } - return vendorsInArea; + public List getVendorsForCustomerBasedOnArea(Map csvFilePaths, String customerFirstName, String customerLastName) throws IOException { + String desiredArea = readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream().filter(customer -> customer.getFirstName().equals(customerFirstName) && customer.getLastName().equals(customerLastName)).iterator().next().getArea(); + return readCsvFile(csvFilePaths.get("vendorFilePath"), Vendor.class).stream().filter(vendor -> vendor.getArea().equals(desiredArea)).collect(Collectors.toList()); } } From 9e3df7fcd0d5d1f6ffb8c36346f3518ee6adf238 Mon Sep 17 00:00:00 2001 From: mniverthi Date: Sun, 11 Oct 2020 00:27:09 -0400 Subject: [PATCH 20/26] finished tests --- .../sf/codingcompetition2020/CodingCompCsvUtil.java | 2 +- .../codingcompetition2020/CodingCompCsvUtilTest.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 44c725e..be3bcc4 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -250,7 +250,7 @@ public List getCustomersBasedOnNumberOfPolicies(String filePath, int n */ public List getVendorsForCustomerBasedOnArea(Map csvFilePaths, String customerFirstName, String customerLastName) throws IOException { String desiredArea = readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream().filter(customer -> customer.getFirstName().equals(customerFirstName) && customer.getLastName().equals(customerLastName)).iterator().next().getArea(); - return readCsvFile(csvFilePaths.get("vendorFilePath"), Vendor.class).stream().filter(vendor -> vendor.getArea().equals(desiredArea)).collect(Collectors.toList()); + return readCsvFile(csvFilePaths.get("vendorList"), Vendor.class).stream().filter(vendor -> vendor.getArea().equals(desiredArea)).collect(Collectors.toList()); } } diff --git a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java index b5d380d..b72cb0d 100644 --- a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java +++ b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java @@ -1,6 +1,7 @@ package sf.codingcompetition2020; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.HashMap; @@ -12,6 +13,7 @@ import sf.codingcompetition2020.structures.Agent; import sf.codingcompetition2020.structures.Claim; import sf.codingcompetition2020.structures.Customer; +import sf.codingcompetition2020.structures.Vendor; public class CodingCompCsvUtilTest{ @@ -134,9 +136,13 @@ public void getVendorsForCustomerBasedOnArea() throws IOException { Map csvFilePaths = new HashMap<>(); csvFilePaths.put(customerList, customerFilePath); csvFilePaths.put(vendorList, vendorFilePath); - System.out.println(codingCompCsVUtil.getVendorsForCustomerBasedOnArea(csvFilePaths, "Alexine", "Spinella").toString()); - System.out.println(codingCompCsVUtil.getVendorsForCustomerBasedOnArea(csvFilePaths, "Brandon", "Dwerryhouse").toString()); - assertEquals(0, 1); + List result = codingCompCsVUtil.getVendorsForCustomerBasedOnArea(csvFilePaths, "Alexine", "Spinella"); + + assertEquals(52, result.size()); + assertEquals(1, result.get(0).getVendorId()); + assertTrue(result.get(0).isInScope()); + assertEquals("area-5", result.get(1).getArea()); + assertEquals(5, result.get(1).getVendorRating()); } } From f88cef465e0c5b019fd55e0f01bd2c7403858249 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 11 Oct 2020 00:30:21 -0400 Subject: [PATCH 21/26] start code cleanup --- .../CodingCompCsvUtil.java | 459 ++++----- .../structures/Agent.java | 348 +++---- .../structures/Claim.java | 294 +++--- .../structures/Customer.java | 890 +++++++++--------- .../structures/Dependent.java | 170 ++-- .../structures/Vendor.java | 294 +++--- .../codingcompetition2020/utilities/Pair.java | 62 +- 7 files changed, 1260 insertions(+), 1257 deletions(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 80fb5e7..76d3a74 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -1,20 +1,5 @@ package sf.codingcompetition2020; -import java.io.FileReader; -import java.io.Reader; -import java.lang.reflect.InvocationTargetException; -import java.util.*; -import java.util.Map.Entry; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.MappingIterator; @@ -23,179 +8,197 @@ import com.fasterxml.jackson.dataformat.csv.CsvParser; import com.fasterxml.jackson.dataformat.csv.CsvSchema; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import java.util.stream.Collectors; + import sf.codingcompetition2020.structures.Agent; import sf.codingcompetition2020.structures.Claim; import sf.codingcompetition2020.structures.Customer; import sf.codingcompetition2020.structures.Vendor; import sf.codingcompetition2020.utilities.Pair; +/** + * This class processes CSV data related to Insurance policy data + * @author Mudit Gupta + * @author Manoj Niverthi + * @version 1.2 + */ public class CodingCompCsvUtil { - - /* #1 - * readCsvFile() -- Read in a CSV File and return a list of entries in that file. - * @param filePath -- Path to file being read in. - * @param classType -- Class of entries being read in. - * @return -- List of entries being returned. - */ - public List readCsvFile(String filePath, Class classType) throws IOException { - List interpretedFile = new ArrayList<>(); - File csvFile = new File(filePath); - CsvMapper mapper = new CsvMapper(); - mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY); - MappingIterator it = mapper.readerFor(Object[].class).readValues(csvFile); - it.nextValue(); - it.forEachRemaining(row -> { - try { - interpretedFile.add(classType.getConstructor(List.class).newInstance(Arrays.asList(row))); - } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - } - }); - if (classType.equals(Customer.class)) { + /* #1 + * readCsvFile() -- Read in a CSV File and return a list of entries in that file. + * @param filePath -- Path to file being read in. + * @param classType -- Class of entries being read in. + * @return -- List of entries being returned. + */ + public List readCsvFile(String filePath, Class classType) throws IOException { + List interpretedFile = new ArrayList<>(); + + File csvFile = new File(filePath); + CsvMapper mapper = new CsvMapper(); + mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY); + MappingIterator it = mapper.readerFor(Object[].class).readValues(csvFile); + it.nextValue(); + it.forEachRemaining(row -> { + try { + interpretedFile.add(classType.getConstructor(List.class).newInstance(Arrays.asList(row))); + } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + }); + if (classType.equals(Customer.class)) { + + } +// FileReader fr = new FileReader(csvFile); +// BufferedReader br = new BufferedReader(fr); +// String entry; +// while ((entry = br.readLine()) != null) { +// List interpretedLine = Arrays.asList(entry.split("\\s*,\\s*")); +// try { +// interpretedFile.add(classType.getConstructor(List.class).newInstance(interpretedLine)); +// } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { +// e.printStackTrace(); +// } +// } + return interpretedFile; + } - } -// FileReader fr = new FileReader(csvFile); -// BufferedReader br = new BufferedReader(fr); -// String entry; -// while ((entry = br.readLine()) != null) { -// List interpretedLine = Arrays.asList(entry.split("\\s*,\\s*")); -// try { -// interpretedFile.add(classType.getConstructor(List.class).newInstance(interpretedLine)); -// } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { -// e.printStackTrace(); -// } -// } - return interpretedFile; - } - - /* #2 - * getAgentCountInArea() -- Return the number of agents in a given area. - * @param filePath -- Path to file being read in. - * @param area -- The area from which the agents should be counted. - * @return -- The number of agents in a given area - */ - public int getAgentCountInArea(String filePath, String area) throws IOException { - return (int) readCsvFile(filePath, Agent.class).stream().filter(agent -> agent.getArea().equals(area)).count(); - } + /* #2 + * getAgentCountInArea() -- Return the number of agents in a given area. + * @param filePath -- Path to file being read in. + * @param area -- The area from which the agents should be counted. + * @return -- The number of agents in a given area + */ + public int getAgentCountInArea(String filePath, String area) throws IOException { + return (int) readCsvFile(filePath, Agent.class).stream().filter(agent -> agent.getArea().equals(area)).count(); + } - - /* #3 - * getAgentsInAreaThatSpeakLanguage() -- Return a list of agents from a given area, that speak a certain language. - * @param filePath -- Path to file being read in. - * @param area -- The area from which the agents should be counted. - * @param language -- The language spoken by the agent(s). - * @return -- The number of agents in a given area - */ - public List getAgentsInAreaThatSpeakLanguage(String filePath, String area, String language) throws IOException { - return readCsvFile(filePath, Agent.class).stream().filter(agent -> agent.getArea().equals(area) && agent.getLanguage().equals(language)).collect(Collectors.toList()); - } - - - /* #4 - * countCustomersFromAreaThatUseAgent() -- Return the number of individuals from an area that use a certain agent. - * @param filePath -- Path to file being read in. - * @param customerArea -- The area from which the customers should be counted. - * @param agentFirstName -- First name of agent. - * @param agentLastName -- Last name of agent. - * @return -- The number of customers that use a certain agent in a given area. - */ - public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, String customerArea, String agentFirstName, String agentLastName) throws IOException { - Agent desiredAgent = (Agent) readCsvFile(csvFilePaths.get("agentList"), Agent.class).stream().filter(agent -> agent.getFirstName().equals(agentFirstName) && agent.getLastName().equals(agentLastName)).toArray()[0]; - return (short) readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream().filter(customer -> customer.getArea().equals(customerArea) && customer.getAgentId() == desiredAgent.getAgentId()).count(); - } - - /* #5 - * getCustomersRetainedForYearsByPlcyCostAsc() -- Return a list of customers retained for a given number of years, in ascending order of their policy cost. - * @param filePath -- Path to file being read in. - * @param yearsOfServeice -- Number of years the person has been a customer. - * @return -- List of customers retained for a given number of years, in ascending order of policy cost. - */ - public List getCustomersRetainedForYearsByPlcyCostAsc(String customerFilePath, short yearsOfService) throws IOException { - return readCsvFile(customerFilePath, Customer.class).stream().filter(customer -> customer.getYearsOfService() == yearsOfService).sorted(Comparator.comparingInt(Customer::getTotalMonthlyPremium)).collect(Collectors.toList()); - } + /* #3 + * getAgentsInAreaThatSpeakLanguage() -- Return a list of agents from a given area, that speak a certain language. + * @param filePath -- Path to file being read in. + * @param area -- The area from which the agents should be counted. + * @param language -- The language spoken by the agent(s). + * @return -- The number of agents in a given area + */ + public List getAgentsInAreaThatSpeakLanguage(String filePath, String area, String language) throws IOException { + return readCsvFile(filePath, Agent.class).stream().filter(agent -> agent.getArea().equals(area) && agent.getLanguage().equals(language)).collect(Collectors.toList()); + } - - /* #6 - * getLeadsForInsurance() -- Return a list of individuals who’ve made an inquiry for a policy but have not signed up. - * *HINT* -- Look for customers that currently have no policies with the insurance company. - * @param filePath -- Path to file being read in. - * @return -- List of customers who’ve made an inquiry for a policy but have not signed up. - */ - public List getLeadsForInsurance(String filePath) throws IOException { - return readCsvFile(filePath, Customer.class).stream().filter(customer -> !customer.hasAutoPolicy() && !customer.hasHomePolicy() && !customer.hasRentersPolicy()).collect(Collectors.toList()); - } + /* #4 + * countCustomersFromAreaThatUseAgent() -- Return the number of individuals from an area that use a certain agent. + * @param filePath -- Path to file being read in. + * @param customerArea -- The area from which the customers should be counted. + * @param agentFirstName -- First name of agent. + * @param agentLastName -- Last name of agent. + * @return -- The number of customers that use a certain agent in a given area. + */ + public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, String customerArea, String agentFirstName, String agentLastName) throws IOException { + Agent desiredAgent = (Agent) readCsvFile(csvFilePaths.get("agentList"), Agent.class).stream().filter(agent -> agent.getFirstName().equals(agentFirstName) && agent.getLastName().equals(agentLastName)).toArray()[0]; + return (short) readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream().filter(customer -> customer.getArea().equals(customerArea) && customer.getAgentId() == desiredAgent.getAgentId()).count(); + } - /* #7 - * getVendorsWithGivenRatingThatAreInScope() -- Return a list of vendors within an area and include options to narrow it down by: - a. Vendor rating - b. Whether that vendor is in scope of the insurance (if inScope == false, return all vendors in OR out of scope, if inScope == true, return ONLY vendors in scope) - * @param filePath -- Path to file being read in. - * @param area -- Area of the vendor. - * @param inScope -- Whether or not the vendor is in scope of the insurance. - * @param vendorRating -- The rating of the vendor. - * @return -- List of vendors within a given area, filtered by scope and vendor rating. - */ - public List getVendorsWithGivenRatingThatAreInScope(String filePath, String area, boolean inScope, int vendorRating) throws IOException { - return readCsvFile(filePath, Vendor.class).stream().filter(vendor -> vendor.getArea().equals(area) && vendor.getVendorRating() >= vendorRating && (!inScope || vendor.isInScope())).collect(Collectors.toList()); - } + /* #5 + * getCustomersRetainedForYearsByPlcyCostAsc() -- Return a list of customers retained for a given number of years, in ascending order of their policy cost. + * @param filePath -- Path to file being read in. + * @param yearsOfServeice -- Number of years the person has been a customer. + * @return -- List of customers retained for a given number of years, in ascending order of policy cost. + */ + public List getCustomersRetainedForYearsByPlcyCostAsc(String customerFilePath, short yearsOfService) throws IOException { + return readCsvFile(customerFilePath, Customer.class).stream().filter(customer -> customer.getYearsOfService() == yearsOfService).sorted(Comparator.comparingInt(Customer::getTotalMonthlyPremium)).collect(Collectors.toList()); + } - /* #8 - * getUndisclosedDrivers() -- Return a list of customers between the age of 40 and 50 years (inclusive), who have: - a. More than X cars - b. less than or equal to X number of dependents. - * @param filePath -- Path to file being read in. - * @param vehiclesInsured -- The number of vehicles insured. - * @param dependents -- The number of dependents on the insurance policy. - * @return -- List of customers filtered by age, number of vehicles insured and the number of dependents. - */ - public List getUndisclosedDrivers(String filePath, int vehiclesInsured, int dependents) throws IOException { - return readCsvFile(filePath, Customer.class).stream().filter(customer -> customer.getAge() >= 40 && customer.getAge() <= 50 && customer.getVehiclesInsured() > vehiclesInsured && customer.getDependents().size() <= dependents).collect(Collectors.toList()); - } + /* #6 + * getLeadsForInsurance() -- Return a list of individuals who’ve made an inquiry for a policy but have not signed up. + * *HINT* -- Look for customers that currently have no policies with the insurance company. + * @param filePath -- Path to file being read in. + * @return -- List of customers who’ve made an inquiry for a policy but have not signed up. + */ + public List getLeadsForInsurance(String filePath) throws IOException { + return readCsvFile(filePath, Customer.class).stream().filter(customer -> !customer.hasAutoPolicy() && !customer.hasHomePolicy() && !customer.hasRentersPolicy()).collect(Collectors.toList()); + } - /* #9 - * getAgentIdGivenRank() -- Return the agent with the given rank based on average customer satisfaction rating. - * *HINT* -- Rating is calculated by taking all the agent rating by customers (1-5 scale) and dividing by the total number - * of reviews for the agent. - * @param filePath -- Path to file being read in. - * @param agentRank -- The rank of the agent being requested. - * @return -- Agent ID of agent with the given rank. - */ - public int getAgentIdGivenRank(String filePath, int agentRank) throws IOException { - List allCustomers = readCsvFile(filePath, Customer.class); - int numberOfAgents = Integer.MIN_VALUE; - for (Customer currentCustomer : allCustomers) { - numberOfAgents = Math.min(numberOfAgents, currentCustomer.getAgentId()); - } - Map> agentRatingsMap = new HashMap<>(); - for (Customer currentCustomer : allCustomers) { - int currentAgentId = currentCustomer.getAgentId(); - int currentAgentRating = currentCustomer.getAgentRating(); - if (agentRatingsMap.containsKey(currentAgentId)) { - List currentAgentList = agentRatingsMap.get(currentAgentId); - currentAgentList.set(0, currentAgentList.get(0) + 1); - currentAgentList.set(1, currentAgentList.get(1) + currentAgentRating); - agentRatingsMap.put(currentAgentId, currentAgentList); - } else { - List newAgentList = new ArrayList<>(); - newAgentList.add(1); - newAgentList.add(currentAgentRating); - agentRatingsMap.put(currentAgentId, newAgentList); - } - } - System.out.println(agentRatingsMap.entrySet().stream().map(entry -> new Pair(entry.getKey(), entry.getValue().stream().mapToInt(rating -> rating).summaryStatistics().getAverage())).sorted((agent1, agent2) -> { - if (agent1.getValue2() > agent2.getValue2()) { - return 1; - } else if (agent1.getValue2() < agent2.getValue2()) { - return -1; - } - return 0; - }).collect(Collectors.toList())); + + /* #7 + * getVendorsWithGivenRatingThatAreInScope() -- Return a list of vendors within an area and include options to narrow it down by: + a. Vendor rating + b. Whether that vendor is in scope of the insurance (if inScope == false, return all vendors in OR out of scope, if inScope == true, return ONLY vendors in scope) + * @param filePath -- Path to file being read in. + * @param area -- Area of the vendor. + * @param inScope -- Whether or not the vendor is in scope of the insurance. + * @param vendorRating -- The rating of the vendor. + * @return -- List of vendors within a given area, filtered by scope and vendor rating. + */ + public List getVendorsWithGivenRatingThatAreInScope(String filePath, String area, boolean inScope, int vendorRating) throws IOException { + return readCsvFile(filePath, Vendor.class).stream().filter(vendor -> vendor.getArea().equals(area) && vendor.getVendorRating() >= vendorRating && (!inScope || vendor.isInScope())).collect(Collectors.toList()); + } + + + /* #8 + * getUndisclosedDrivers() -- Return a list of customers between the age of 40 and 50 years (inclusive), who have: + a. More than X cars + b. less than or equal to X number of dependents. + * @param filePath -- Path to file being read in. + * @param vehiclesInsured -- The number of vehicles insured. + * @param dependents -- The number of dependents on the insurance policy. + * @return -- List of customers filtered by age, number of vehicles insured and the number of dependents. + */ + public List getUndisclosedDrivers(String filePath, int vehiclesInsured, int dependents) throws IOException { + return readCsvFile(filePath, Customer.class).stream().filter(customer -> customer.getAge() >= 40 && customer.getAge() <= 50 && customer.getVehiclesInsured() > vehiclesInsured && customer.getDependents().size() <= dependents).collect(Collectors.toList()); + } + + + /* #9 + * getAgentIdGivenRank() -- Return the agent with the given rank based on average customer satisfaction rating. + * *HINT* -- Rating is calculated by taking all the agent rating by customers (1-5 scale) and dividing by the total number + * of reviews for the agent. + * @param filePath -- Path to file being read in. + * @param agentRank -- The rank of the agent being requested. + * @return -- Agent ID of agent with the given rank. + */ + public int getAgentIdGivenRank(String filePath, int agentRank) throws IOException { + List allCustomers = readCsvFile(filePath, Customer.class); + int numberOfAgents = Integer.MIN_VALUE; + for (Customer currentCustomer : allCustomers) { + numberOfAgents = Math.min(numberOfAgents, currentCustomer.getAgentId()); + } + Map> agentRatingsMap = new HashMap<>(); + for (Customer currentCustomer : allCustomers) { + int currentAgentId = currentCustomer.getAgentId(); + int currentAgentRating = currentCustomer.getAgentRating(); + if (agentRatingsMap.containsKey(currentAgentId)) { + List currentAgentList = agentRatingsMap.get(currentAgentId); + currentAgentList.set(0, currentAgentList.get(0) + 1); + currentAgentList.set(1, currentAgentList.get(1) + currentAgentRating); + agentRatingsMap.put(currentAgentId, currentAgentList); + } else { + List newAgentList = new ArrayList<>(); + newAgentList.add(1); + newAgentList.add(currentAgentRating); + agentRatingsMap.put(currentAgentId, newAgentList); + } + } + System.out.println(agentRatingsMap.entrySet().stream().map(entry -> new Pair(entry.getKey(), entry.getValue().stream().mapToInt(rating -> rating).summaryStatistics().getAverage())).sorted((agent1, agent2) -> { + if (agent1.getValue2() > agent2.getValue2()) { + return 1; + } else if (agent1.getValue2() < agent2.getValue2()) { + return -1; + } + return 0; + }).collect(Collectors.toList())); return ((Pair) agentRatingsMap.entrySet().stream().map(entry -> new Pair(entry.getKey(), entry.getValue().stream().mapToInt(rating -> rating).summaryStatistics().getAverage())).sorted((agent1, agent2) -> { if (agent1.getValue2() > agent2.getValue2()) { return 1; @@ -206,67 +209,67 @@ public int getAgentIdGivenRank(String filePath, int agentRank) throws IOExceptio }).skip(agentRank-1).limit(1).toArray()[0]).getValue1(); // // List> agentAverageRatings = new ArrayList<>(); -// for (Map.Entry> entry : agentRatingsMap.entrySet()) { -// Integer agentId = entry.getKey(); -// Integer numReviews = entry.getValue().get(0); -// Integer totalRating = entry.getValue().get(1); -// Double averageRating = (double)(totalRating) / numReviews; -// agentAverageRatings.add(new Pair<>(agentId, averageRating)); -// } -// Collections.sort(entryList, (o1, o2) -> { -// if (o1.getValue2() > o2.getValue2()) { -// return 1; -// } else if (o1.getValue2() < o2.getValue2()) { -// return -1; -// } -// return 0; -// }); -// return agentAverageRatings.get(agentRank - 1).getValue1(); - } +// for (Map.Entry> entry : agentRatingsMap.entrySet()) { +// Integer agentId = entry.getKey(); +// Integer numReviews = entry.getValue().get(0); +// Integer totalRating = entry.getValue().get(1); +// Double averageRating = (double)(totalRating) / numReviews; +// agentAverageRatings.add(new Pair<>(agentId, averageRating)); +// } +// Collections.sort(entryList, (o1, o2) -> { +// if (o1.getValue2() > o2.getValue2()) { +// return 1; +// } else if (o1.getValue2() < o2.getValue2()) { +// return -1; +// } +// return 0; +// }); +// return agentAverageRatings.get(agentRank - 1).getValue1(); + } + - - /* #10 - * getCustomersWithClaims() -- Return a list of customers who’ve filed a claim within the last (inclusive). - * @param filePath -- Path to file being read in. - * @param monthsOpen -- Number of months a policy has been open. - * @return -- List of customers who’ve filed a claim within the last . - */ - public List getCustomersWithClaims(Map csvFilePaths, short monthsOpen) throws IOException { - List customerIDsWithRecentClaim = readCsvFile(csvFilePaths.get("claimList"), Claim.class).stream().filter(claim -> claim.getMonthsOpen() <= monthsOpen).map(claim -> claim.getCustomerId()).collect(Collectors.toList()); + /* #10 + * getCustomersWithClaims() -- Return a list of customers who’ve filed a claim within the last (inclusive). + * @param filePath -- Path to file being read in. + * @param monthsOpen -- Number of months a policy has been open. + * @return -- List of customers who’ve filed a claim within the last . + */ + public List getCustomersWithClaims(Map csvFilePaths, short monthsOpen) throws IOException { + List customerIDsWithRecentClaim = readCsvFile(csvFilePaths.get("claimList"), Claim.class).stream().filter(claim -> claim.getMonthsOpen() <= monthsOpen).map(claim -> claim.getCustomerId()).collect(Collectors.toList()); return readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream().filter(customer -> customerIDsWithRecentClaim.contains(customer.getCustomerId())).collect(Collectors.toList()); - } + } - /* Custom methods: 1 - * getCustomersBasedOnNumberOfPolicies() -- Return a list of customers who have policies (inclusive). - * @param filePath -- Path to file being read in. - * @param numberOfPolicies -- Number of months a policy has been open. - * @return -- List of customers who have policies. - */ - public List getCustomersBasedOnNumberOfPolicies(String filePath, int numberOfPolicies) throws IOException { - return readCsvFile(filePath, Customer.class).stream().filter(customer -> { - int policyCount = 0; - if (customer.hasAutoPolicy()) { - policyCount++; - } - if (customer.hasHomePolicy()) { - policyCount++; - } - if (customer.hasRentersPolicy()) { - policyCount++; - } - return policyCount == numberOfPolicies; - }).collect(Collectors.toList()); - } + /* Custom methods: 1 + * getCustomersBasedOnNumberOfPolicies() -- Return a list of customers who have policies (inclusive). + * @param filePath -- Path to file being read in. + * @param numberOfPolicies -- Number of months a policy has been open. + * @return -- List of customers who have policies. + */ + public List getCustomersBasedOnNumberOfPolicies(String filePath, int numberOfPolicies) throws IOException { + return readCsvFile(filePath, Customer.class).stream().filter(customer -> { + int policyCount = 0; + if (customer.hasAutoPolicy()) { + policyCount++; + } + if (customer.hasHomePolicy()) { + policyCount++; + } + if (customer.hasRentersPolicy()) { + policyCount++; + } + return policyCount == numberOfPolicies; + }).collect(Collectors.toList()); + } - /* Custom methods: 2 - * getVendorsForCustomerBasedOnArea() -- Return a list of vendors that operate in the area of a given customer. - * @param csvFilePaths -- Paths to files being read in. - * @param customerFirstName -- last name of customer - * @param customerLastName -- first name of customer - * @return -- list of vendors that operate in the area of a given customer - */ - public List getVendorsForCustomerBasedOnArea(Map csvFilePaths, String customerFirstName, String customerLastName) throws IOException { - String desiredArea = readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream().filter(customer -> customer.getFirstName().equals(customerFirstName) && customer.getLastName().equals(customerLastName)).iterator().next().getArea(); - return readCsvFile(csvFilePaths.get("vendorFilePath"), Vendor.class).stream().filter(vendor -> vendor.getArea().equals(desiredArea)).collect(Collectors.toList()); - } + /* Custom methods: 2 + * getVendorsForCustomerBasedOnArea() -- Return a list of vendors that operate in the area of a given customer. + * @param csvFilePaths -- Paths to files being read in. + * @param customerFirstName -- last name of customer + * @param customerLastName -- first name of customer + * @return -- list of vendors that operate in the area of a given customer + */ + public List getVendorsForCustomerBasedOnArea(Map csvFilePaths, String customerFirstName, String customerLastName) throws IOException { + String desiredArea = readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream().filter(customer -> customer.getFirstName().equals(customerFirstName) && customer.getLastName().equals(customerLastName)).iterator().next().getArea(); + return readCsvFile(csvFilePaths.get("vendorFilePath"), Vendor.class).stream().filter(vendor -> vendor.getArea().equals(desiredArea)).collect(Collectors.toList()); + } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Agent.java b/src/main/java/sf/codingcompetition2020/structures/Agent.java index 6875f84..c99fc65 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Agent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Agent.java @@ -4,178 +4,178 @@ public class Agent { - private int agentId; - private String area; - private String language; - private String firstName; - private String lastName; - - /** - * Default Agent constructor - */ - private Agent(int agentId, String area, String language, String firstName, String lastName) { - this.agentId = agentId; - this.area = area; - this.language = language; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * constructor based on an entry in a CSV - * @param csvEntry - */ - public Agent(List csvEntry) { - this( - Integer.parseInt(csvEntry.get(0)), - csvEntry.get(1), - csvEntry.get(2), - csvEntry.get(3), - csvEntry.get(4)); - } - - /** - * Builder constructor - * @param builder - */ - public Agent(Builder builder) { - this( - builder.agentId, - builder.area, - builder.language, - builder.firstName, - builder.lastName); - } - - /** - * Returns value of agentId - * @return - */ - public int getAgentId() { - return agentId; - } - - /** - * Sets new value of agentId - * @param - */ - public void setAgentId(int agentId) { - this.agentId = agentId; - } - - /** - * Returns value of area - * @return - */ - public String getArea() { - return area; - } - - /** - * Sets new value of area - * @param - */ - public void setArea(String area) { - this.area = area; - } - - /** - * Returns value of language - * @return - */ - public String getLanguage() { - return language; - } - - /** - * Sets new value of language - * @param - */ - public void setLanguage(String language) { - this.language = language; - } - - /** - * Returns value of firstName - * @return - */ - public String getFirstName() { - return firstName; - } - - /** - * Sets new value of firstName - * @param - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - /** - * Returns value of lastName - * @return - */ - public String getLastName() { - return lastName; - } - - /** - * Sets new value of lastName - * @param - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } - - @Override - public String toString() { - return "Agent{" + - "agentId=" + agentId + - ", area='" + area + '\'' + - ", language='" + language + '\'' + - ", firstName='" + firstName + '\'' + - ", lastName='" + lastName + '\'' + - '}'; - } - - public static class Builder { - private int agentId; - private String area; - private String language; - private String firstName; - private String lastName; - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder agentId(int agentId) { - this.agentId = agentId; - return this; - } - - public Builder area(String area) { - this.area = area; - return this; - } - - public Builder language(String language) { - this.language = language; - return this; - } - - public Builder firstName(String firstName) { - this.firstName = firstName; - return this; - } - - public Builder lastName(String lastName) { - this.lastName = lastName; - return this; - } - - public Agent build() { - return new Agent(this); - } - } + private int agentId; + private String area; + private String language; + private String firstName; + private String lastName; + + /** + * Default Agent constructor + */ + private Agent(int agentId, String area, String language, String firstName, String lastName) { + this.agentId = agentId; + this.area = area; + this.language = language; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * constructor based on an entry in a CSV + * @param csvEntry + */ + public Agent(List csvEntry) { + this( + Integer.parseInt(csvEntry.get(0)), + csvEntry.get(1), + csvEntry.get(2), + csvEntry.get(3), + csvEntry.get(4)); + } + + /** + * Builder constructor + * @param builder + */ + public Agent(Builder builder) { + this( + builder.agentId, + builder.area, + builder.language, + builder.firstName, + builder.lastName); + } + + /** + * Returns value of agentId + * @return + */ + public int getAgentId() { + return agentId; + } + + /** + * Sets new value of agentId + * @param + */ + public void setAgentId(int agentId) { + this.agentId = agentId; + } + + /** + * Returns value of area + * @return + */ + public String getArea() { + return area; + } + + /** + * Sets new value of area + * @param + */ + public void setArea(String area) { + this.area = area; + } + + /** + * Returns value of language + * @return + */ + public String getLanguage() { + return language; + } + + /** + * Sets new value of language + * @param + */ + public void setLanguage(String language) { + this.language = language; + } + + /** + * Returns value of firstName + * @return + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets new value of firstName + * @param + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * Returns value of lastName + * @return + */ + public String getLastName() { + return lastName; + } + + /** + * Sets new value of lastName + * @param + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @Override + public String toString() { + return "Agent{" + + "agentId=" + agentId + + ", area='" + area + '\'' + + ", language='" + language + '\'' + + ", firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + '}'; + } + + public static class Builder { + private int agentId; + private String area; + private String language; + private String firstName; + private String lastName; + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder agentId(int agentId) { + this.agentId = agentId; + return this; + } + + public Builder area(String area) { + this.area = area; + return this; + } + + public Builder language(String language) { + this.language = language; + return this; + } + + public Builder firstName(String firstName) { + this.firstName = firstName; + return this; + } + + public Builder lastName(String lastName) { + this.lastName = lastName; + return this; + } + + public Agent build() { + return new Agent(this); + } + } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Claim.java b/src/main/java/sf/codingcompetition2020/structures/Claim.java index 20aaccc..216fed0 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Claim.java +++ b/src/main/java/sf/codingcompetition2020/structures/Claim.java @@ -4,152 +4,152 @@ public class Claim { - private int claimId; - private int customerId; - private boolean closed; - private int monthsOpen; - - /** - * Default Claim constructor - */ - public Claim(int claimId, int customerId, boolean closed, int monthsOpen) { - this.claimId = claimId; - this.customerId = customerId; - this.closed = closed; - this.monthsOpen = monthsOpen; - } - - /** - * constructor based on an entry in a CSV - * @param csvEntry - */ - public Claim(List csvEntry) { - this( - Integer.parseInt(csvEntry.get(0)), - Integer.parseInt(csvEntry.get(1)), - Boolean.parseBoolean(csvEntry.get(2)), - Integer.parseInt(csvEntry.get(3))); - } - - /** - * Builder constructor - * @param builder - */ - public Claim(Builder builder) { - this( - builder.claimId, - builder.customerId, - builder.closed, - builder.monthsOpen); - } - - /** - * Returns value of claimId - * @return - */ - public int getClaimId() { - return claimId; - } - - /** - * Sets new value of claimId - * @param - */ - public void setClaimId(int claimId) { - this.claimId = claimId; - } - - /** - * Returns value of customerId - * @return - */ - public int getCustomerId() { - return customerId; - } - - /** - * Sets new value of customerId - * @param - */ - public void setCustomerId(int customerId) { - this.customerId = customerId; - } - - /** - * Returns value of closed - * @return - */ - public boolean isClosed() { - return closed; - } - - /** - * Sets new value of closed - * @param - */ - public void setClosed(boolean closed) { - this.closed = closed; - } - - /** - * Returns value of monthsOpen - * @return - */ - public int getMonthsOpen() { - return monthsOpen; - } - - /** - * Sets new value of monthsOpen - * @param - */ - public void setMonthsOpen(int monthsOpen) { - this.monthsOpen = monthsOpen; - } - - @Override - public String toString() { - return "Claim{" + - "claimId=" + claimId + - ", customerId=" + customerId + - ", closed=" + closed + - ", monthsOpen=" + monthsOpen + - '}'; - } - - public static class Builder { - private int claimId; - private int customerId; - private boolean closed; - private int monthsOpen; - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder claimId(int claimId) { - this.claimId = claimId; - return this; - } - - public Builder customerId(int customerId) { - this.customerId = customerId; - return this; - } - - public Builder closed(boolean closed) { - this.closed = closed; - return this; - } - - public Builder monthsOpen(int monthsOpen) { - this.monthsOpen = monthsOpen; - return this; - } - - public Claim build() { - return new Claim(this); - } - } + private int claimId; + private int customerId; + private boolean closed; + private int monthsOpen; + + /** + * Default Claim constructor + */ + public Claim(int claimId, int customerId, boolean closed, int monthsOpen) { + this.claimId = claimId; + this.customerId = customerId; + this.closed = closed; + this.monthsOpen = monthsOpen; + } + + /** + * constructor based on an entry in a CSV + * @param csvEntry + */ + public Claim(List csvEntry) { + this( + Integer.parseInt(csvEntry.get(0)), + Integer.parseInt(csvEntry.get(1)), + Boolean.parseBoolean(csvEntry.get(2)), + Integer.parseInt(csvEntry.get(3))); + } + + /** + * Builder constructor + * @param builder + */ + public Claim(Builder builder) { + this( + builder.claimId, + builder.customerId, + builder.closed, + builder.monthsOpen); + } + + /** + * Returns value of claimId + * @return + */ + public int getClaimId() { + return claimId; + } + + /** + * Sets new value of claimId + * @param + */ + public void setClaimId(int claimId) { + this.claimId = claimId; + } + + /** + * Returns value of customerId + * @return + */ + public int getCustomerId() { + return customerId; + } + + /** + * Sets new value of customerId + * @param + */ + public void setCustomerId(int customerId) { + this.customerId = customerId; + } + + /** + * Returns value of closed + * @return + */ + public boolean isClosed() { + return closed; + } + + /** + * Sets new value of closed + * @param + */ + public void setClosed(boolean closed) { + this.closed = closed; + } + + /** + * Returns value of monthsOpen + * @return + */ + public int getMonthsOpen() { + return monthsOpen; + } + + /** + * Sets new value of monthsOpen + * @param + */ + public void setMonthsOpen(int monthsOpen) { + this.monthsOpen = monthsOpen; + } + + @Override + public String toString() { + return "Claim{" + + "claimId=" + claimId + + ", customerId=" + customerId + + ", closed=" + closed + + ", monthsOpen=" + monthsOpen + + '}'; + } + + public static class Builder { + private int claimId; + private int customerId; + private boolean closed; + private int monthsOpen; + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder claimId(int claimId) { + this.claimId = claimId; + return this; + } + + public Builder customerId(int customerId) { + this.customerId = customerId; + return this; + } + + public Builder closed(boolean closed) { + this.closed = closed; + return this; + } + + public Builder monthsOpen(int monthsOpen) { + this.monthsOpen = monthsOpen; + return this; + } + + public Claim build() { + return new Claim(this); + } + } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Customer.java b/src/main/java/sf/codingcompetition2020/structures/Customer.java index 2f8c41b..1258893 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Customer.java +++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java @@ -11,449 +11,449 @@ public class Customer { - private int customerId; - private String firstName; - private String lastName; - private int age; - private String area; - private int agentId; - private short agentRating; - private String primaryLanguage; - private List dependents; - private boolean homePolicy; - private boolean autoPolicy; - private boolean rentersPolicy; - private int totalMonthlyPremium; - private short yearsOfService; - private int vehiclesInsured; - - /** - * Default Customer constructor - */ - public Customer(int customerId, String firstName, String lastName, int age, String area, int agentId, short agentRating, String primaryLanguage, List dependents, boolean homePolicy, boolean autoPolicy, boolean rentersPolicy, String totalMonthlyPremium, short yearsOfService, int vehiclesInsured) { - this.customerId = customerId; - this.firstName = firstName; - this.lastName = lastName; - this.age = age; - this.area = area; - this.agentId = agentId; - this.agentRating = agentRating; - this.primaryLanguage = primaryLanguage; - this.dependents = dependents; - this.homePolicy = homePolicy; - this.autoPolicy = autoPolicy; - this.rentersPolicy = rentersPolicy; - this.totalMonthlyPremium = Integer.parseInt(totalMonthlyPremium.substring(1)); - this.yearsOfService = yearsOfService; - this.vehiclesInsured = vehiclesInsured; - } - - /** - * constructor based on an entry in a CSV - * @param csvEntry - */ - public Customer(List csvEntry) throws JsonProcessingException { - this( - Integer.parseInt(csvEntry.get(0)), - csvEntry.get(1), - csvEntry.get(2), - Integer.parseInt(csvEntry.get(3)), - csvEntry.get(4), - Integer.parseInt(csvEntry.get(5)), - Short.parseShort(csvEntry.get(6)), - csvEntry.get(7), - csvEntry.get(8).isEmpty() ? new ArrayList<>() : new ObjectMapper().readValue(csvEntry.get(8), new TypeReference>(){}), - Boolean.parseBoolean(csvEntry.get(9)), - Boolean.parseBoolean(csvEntry.get(10)), - Boolean.parseBoolean(csvEntry.get(11)), - csvEntry.get(12), - Short.parseShort(csvEntry.get(13)), - Integer.parseInt(csvEntry.get(14)) - ); - } - - /** - * Builder constructor - * @param builder - */ - public Customer(Builder builder) { - this( - builder.customerId, - builder.firstName, - builder.lastName, - builder.age, - builder.area, - builder.agentId, - builder.agentRating, - builder.primaryLanguage, - builder.dependents, - builder.homePolicy, - builder.autoPolicy, - builder.rentersPolicy, - builder.totalMonthlyPremium, - builder.yearsOfService, - builder.vehiclesInsured); - } - - /** - * Returns value of customerId - * @return - */ - public int getCustomerId() { - return customerId; - } - - /** - * Sets new value of customerId - * @param - */ - public void setCustomerId(int customerId) { - this.customerId = customerId; - } - - /** - * Returns value of firstName - * @return - */ - public String getFirstName() { - return firstName; - } - - /** - * Sets new value of firstName - * @param - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - /** - * Returns value of lastName - * @return - */ - public String getLastName() { - return lastName; - } - - /** - * Sets new value of lastName - * @param - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } - - /** - * Returns value of age - * @return - */ - public int getAge() { - return age; - } - - /** - * Sets new value of age - * @param - */ - public void setAge(int age) { - this.age = age; - } - - /** - * Returns value of area - * @return - */ - public String getArea() { - return area; - } - - /** - * Sets new value of area - * @param - */ - public void setArea(String area) { - this.area = area; - } - - /** - * Returns value of agentId - * @return - */ - public int getAgentId() { - return agentId; - } - - /** - * Sets new value of agentId - * @param - */ - public void setAgentId(int agentId) { - this.agentId = agentId; - } - - /** - * Returns value of agentRating - * @return - */ - public short getAgentRating() { - return agentRating; - } - - /** - * Sets new value of agentRating - * @param - */ - public void setAgentRating(short agentRating) { - this.agentRating = agentRating; - } - - /** - * Returns value of primaryLanguage - * @return - */ - public String getPrimaryLanguage() { - return primaryLanguage; - } - - /** - * Sets new value of primaryLanguage - * @param - */ - public void setPrimaryLanguage(String primaryLanguage) { - this.primaryLanguage = primaryLanguage; - } - - /** - * Returns value of dependents - * @return - */ - public List getDependents() { - return dependents; - } - - /** - * Sets new value of dependents - * @param - */ - public void setDependents(List dependents) { - this.dependents = dependents; - } - - /** - * Returns value of homePolicy - * @return - */ - public boolean hasHomePolicy() { - return homePolicy; - } - - /** - * Sets new value of homePolicy - * @param - */ - public void setHomePolicy(boolean homePolicy) { - this.homePolicy = homePolicy; - } - - /** - * Returns value of autoPolicy - * @return - */ - public boolean hasAutoPolicy() { - return autoPolicy; - } - - /** - * Sets new value of autoPolicy - * @param - */ - public void setAutoPolicy(boolean autoPolicy) { - this.autoPolicy = autoPolicy; - } - - /** - * Returns value of rentersPolicy - * @return - */ - public boolean hasRentersPolicy() { - return rentersPolicy; - } - - /** - * Sets new value of rentersPolicy - * @param - */ - public void setRentersPolicy(boolean rentersPolicy) { - this.rentersPolicy = rentersPolicy; - } - - /** - * Returns value of totalMonthlyPremium - * @return - */ - public int getTotalMonthlyPremium() { - return totalMonthlyPremium; - } - - /** - * Sets new value of totalMonthlyPremium - * @param - */ - public void setTotalMonthlyPremium(String totalMonthlyPremium) { - this.totalMonthlyPremium = Integer.parseInt(totalMonthlyPremium.substring(1)); - } - - /** - * Returns value of yearsOfService - * @return - */ - public short getYearsOfService() { - return yearsOfService; - } - - /** - * Sets new value of yearsOfService - * @param - */ - public void setYearsOfService(short yearsOfService) { - this.yearsOfService = yearsOfService; - } - - /** - * Returns value of vehiclesInsured - * @return - */ - public int getVehiclesInsured() { - return vehiclesInsured; - } - - /** - * Sets new value of vehiclesInsured - * @param - */ - public void setVehiclesInsured(int vehiclesInsured) { - this.vehiclesInsured = vehiclesInsured; - } - - @Override - public String toString() { - return "Customer{" + - "customerId=" + customerId + - ", firstName='" + firstName + '\'' + - ", lastName='" + lastName + '\'' + - ", age=" + age + - ", area='" + area + '\'' + - ", agentId=" + agentId + - ", agentRating=" + agentRating + - ", primaryLanguage='" + primaryLanguage + '\'' + - ", dependents=" + dependents + - ", homePolicy=" + homePolicy + - ", autoPolicy=" + autoPolicy + - ", rentersPolicy=" + rentersPolicy + - ", totalMonthlyPremium=" + totalMonthlyPremium + - ", yearsOfService=" + yearsOfService + - ", vehiclesInsured=" + vehiclesInsured + - '}'; - } - - public static class Builder { - private int customerId; - private String firstName; - private String lastName; - private int age; - private String area; - private int agentId; - private short agentRating; - private String primaryLanguage; - private List dependents; - private boolean homePolicy; - private boolean autoPolicy; - private boolean rentersPolicy; - private String totalMonthlyPremium; - private short yearsOfService; - private int vehiclesInsured; - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder customerId(int customerId) { - this.customerId = customerId; - return this; - } - - public Builder firstName(String firstName) { - this.firstName = firstName; - return this; - } - - public Builder lastName(String lastName) { - this.lastName = lastName; - return this; - } - - public Builder age(int age) { - this.age = age; - return this; - } - - public Builder area(String area) { - this.area = area; - return this; - } - - public Builder agentId(int agentId) { - this.agentId = agentId; - return this; - } - - public Builder agentRating(short agentRating) { - this.agentRating = agentRating; - return this; - } - - public Builder primaryLanguage(String primaryLanguage) { - this.primaryLanguage = primaryLanguage; - return this; - } - - public Builder dependents(List dependents) { - this.dependents = dependents; - return this; - } - - public Builder homePolicy(boolean homePolicy) { - this.homePolicy = homePolicy; - return this; - } - - public Builder autoPolicy(boolean autoPolicy) { - this.autoPolicy = autoPolicy; - return this; - } - - public Builder rentersPolicy(boolean rentersPolicy) { - this.rentersPolicy = rentersPolicy; - return this; - } - - public Builder totalMonthlyPremium(String totalMonthlyPremium) { - this.totalMonthlyPremium = totalMonthlyPremium; - return this; - } - - public Builder yearsOfService(short yearsOfService) { - this.yearsOfService = yearsOfService; - return this; - } - - public Builder vehiclesInsured(int vehiclesInsured) { - this.vehiclesInsured = vehiclesInsured; - return this; - } - - public Customer build() { - return new Customer(this); - } - } + private int customerId; + private String firstName; + private String lastName; + private int age; + private String area; + private int agentId; + private short agentRating; + private String primaryLanguage; + private List dependents; + private boolean homePolicy; + private boolean autoPolicy; + private boolean rentersPolicy; + private int totalMonthlyPremium; + private short yearsOfService; + private int vehiclesInsured; + + /** + * Default Customer constructor + */ + public Customer(int customerId, String firstName, String lastName, int age, String area, int agentId, short agentRating, String primaryLanguage, List dependents, boolean homePolicy, boolean autoPolicy, boolean rentersPolicy, String totalMonthlyPremium, short yearsOfService, int vehiclesInsured) { + this.customerId = customerId; + this.firstName = firstName; + this.lastName = lastName; + this.age = age; + this.area = area; + this.agentId = agentId; + this.agentRating = agentRating; + this.primaryLanguage = primaryLanguage; + this.dependents = dependents; + this.homePolicy = homePolicy; + this.autoPolicy = autoPolicy; + this.rentersPolicy = rentersPolicy; + this.totalMonthlyPremium = Integer.parseInt(totalMonthlyPremium.substring(1)); + this.yearsOfService = yearsOfService; + this.vehiclesInsured = vehiclesInsured; + } + + /** + * constructor based on an entry in a CSV + * @param csvEntry + */ + public Customer(List csvEntry) throws JsonProcessingException { + this( + Integer.parseInt(csvEntry.get(0)), + csvEntry.get(1), + csvEntry.get(2), + Integer.parseInt(csvEntry.get(3)), + csvEntry.get(4), + Integer.parseInt(csvEntry.get(5)), + Short.parseShort(csvEntry.get(6)), + csvEntry.get(7), + csvEntry.get(8).isEmpty() ? new ArrayList<>() : new ObjectMapper().readValue(csvEntry.get(8), new TypeReference>(){}), + Boolean.parseBoolean(csvEntry.get(9)), + Boolean.parseBoolean(csvEntry.get(10)), + Boolean.parseBoolean(csvEntry.get(11)), + csvEntry.get(12), + Short.parseShort(csvEntry.get(13)), + Integer.parseInt(csvEntry.get(14)) + ); + } + + /** + * Builder constructor + * @param builder + */ + public Customer(Builder builder) { + this( + builder.customerId, + builder.firstName, + builder.lastName, + builder.age, + builder.area, + builder.agentId, + builder.agentRating, + builder.primaryLanguage, + builder.dependents, + builder.homePolicy, + builder.autoPolicy, + builder.rentersPolicy, + builder.totalMonthlyPremium, + builder.yearsOfService, + builder.vehiclesInsured); + } + + /** + * Returns value of customerId + * @return + */ + public int getCustomerId() { + return customerId; + } + + /** + * Sets new value of customerId + * @param + */ + public void setCustomerId(int customerId) { + this.customerId = customerId; + } + + /** + * Returns value of firstName + * @return + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets new value of firstName + * @param + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * Returns value of lastName + * @return + */ + public String getLastName() { + return lastName; + } + + /** + * Sets new value of lastName + * @param + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * Returns value of age + * @return + */ + public int getAge() { + return age; + } + + /** + * Sets new value of age + * @param + */ + public void setAge(int age) { + this.age = age; + } + + /** + * Returns value of area + * @return + */ + public String getArea() { + return area; + } + + /** + * Sets new value of area + * @param + */ + public void setArea(String area) { + this.area = area; + } + + /** + * Returns value of agentId + * @return + */ + public int getAgentId() { + return agentId; + } + + /** + * Sets new value of agentId + * @param + */ + public void setAgentId(int agentId) { + this.agentId = agentId; + } + + /** + * Returns value of agentRating + * @return + */ + public short getAgentRating() { + return agentRating; + } + + /** + * Sets new value of agentRating + * @param + */ + public void setAgentRating(short agentRating) { + this.agentRating = agentRating; + } + + /** + * Returns value of primaryLanguage + * @return + */ + public String getPrimaryLanguage() { + return primaryLanguage; + } + + /** + * Sets new value of primaryLanguage + * @param + */ + public void setPrimaryLanguage(String primaryLanguage) { + this.primaryLanguage = primaryLanguage; + } + + /** + * Returns value of dependents + * @return + */ + public List getDependents() { + return dependents; + } + + /** + * Sets new value of dependents + * @param + */ + public void setDependents(List dependents) { + this.dependents = dependents; + } + + /** + * Returns value of homePolicy + * @return + */ + public boolean hasHomePolicy() { + return homePolicy; + } + + /** + * Sets new value of homePolicy + * @param + */ + public void setHomePolicy(boolean homePolicy) { + this.homePolicy = homePolicy; + } + + /** + * Returns value of autoPolicy + * @return + */ + public boolean hasAutoPolicy() { + return autoPolicy; + } + + /** + * Sets new value of autoPolicy + * @param + */ + public void setAutoPolicy(boolean autoPolicy) { + this.autoPolicy = autoPolicy; + } + + /** + * Returns value of rentersPolicy + * @return + */ + public boolean hasRentersPolicy() { + return rentersPolicy; + } + + /** + * Sets new value of rentersPolicy + * @param + */ + public void setRentersPolicy(boolean rentersPolicy) { + this.rentersPolicy = rentersPolicy; + } + + /** + * Returns value of totalMonthlyPremium + * @return + */ + public int getTotalMonthlyPremium() { + return totalMonthlyPremium; + } + + /** + * Sets new value of totalMonthlyPremium + * @param + */ + public void setTotalMonthlyPremium(String totalMonthlyPremium) { + this.totalMonthlyPremium = Integer.parseInt(totalMonthlyPremium.substring(1)); + } + + /** + * Returns value of yearsOfService + * @return + */ + public short getYearsOfService() { + return yearsOfService; + } + + /** + * Sets new value of yearsOfService + * @param + */ + public void setYearsOfService(short yearsOfService) { + this.yearsOfService = yearsOfService; + } + + /** + * Returns value of vehiclesInsured + * @return + */ + public int getVehiclesInsured() { + return vehiclesInsured; + } + + /** + * Sets new value of vehiclesInsured + * @param + */ + public void setVehiclesInsured(int vehiclesInsured) { + this.vehiclesInsured = vehiclesInsured; + } + + @Override + public String toString() { + return "Customer{" + + "customerId=" + customerId + + ", firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + ", age=" + age + + ", area='" + area + '\'' + + ", agentId=" + agentId + + ", agentRating=" + agentRating + + ", primaryLanguage='" + primaryLanguage + '\'' + + ", dependents=" + dependents + + ", homePolicy=" + homePolicy + + ", autoPolicy=" + autoPolicy + + ", rentersPolicy=" + rentersPolicy + + ", totalMonthlyPremium=" + totalMonthlyPremium + + ", yearsOfService=" + yearsOfService + + ", vehiclesInsured=" + vehiclesInsured + + '}'; + } + + public static class Builder { + private int customerId; + private String firstName; + private String lastName; + private int age; + private String area; + private int agentId; + private short agentRating; + private String primaryLanguage; + private List dependents; + private boolean homePolicy; + private boolean autoPolicy; + private boolean rentersPolicy; + private String totalMonthlyPremium; + private short yearsOfService; + private int vehiclesInsured; + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder customerId(int customerId) { + this.customerId = customerId; + return this; + } + + public Builder firstName(String firstName) { + this.firstName = firstName; + return this; + } + + public Builder lastName(String lastName) { + this.lastName = lastName; + return this; + } + + public Builder age(int age) { + this.age = age; + return this; + } + + public Builder area(String area) { + this.area = area; + return this; + } + + public Builder agentId(int agentId) { + this.agentId = agentId; + return this; + } + + public Builder agentRating(short agentRating) { + this.agentRating = agentRating; + return this; + } + + public Builder primaryLanguage(String primaryLanguage) { + this.primaryLanguage = primaryLanguage; + return this; + } + + public Builder dependents(List dependents) { + this.dependents = dependents; + return this; + } + + public Builder homePolicy(boolean homePolicy) { + this.homePolicy = homePolicy; + return this; + } + + public Builder autoPolicy(boolean autoPolicy) { + this.autoPolicy = autoPolicy; + return this; + } + + public Builder rentersPolicy(boolean rentersPolicy) { + this.rentersPolicy = rentersPolicy; + return this; + } + + public Builder totalMonthlyPremium(String totalMonthlyPremium) { + this.totalMonthlyPremium = totalMonthlyPremium; + return this; + } + + public Builder yearsOfService(short yearsOfService) { + this.yearsOfService = yearsOfService; + return this; + } + + public Builder vehiclesInsured(int vehiclesInsured) { + this.vehiclesInsured = vehiclesInsured; + return this; + } + + public Customer build() { + return new Customer(this); + } + } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Dependent.java b/src/main/java/sf/codingcompetition2020/structures/Dependent.java index cb34382..df3c6d8 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Dependent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Dependent.java @@ -3,101 +3,101 @@ import java.util.List; public class Dependent { - private String firstName; - private String lastName; + private String firstName; + private String lastName; - /** - * - */ - public Dependent() { - super(); - } - /** - * constructor based on an entry in a CSV - * @param csvEntry - */ - public Dependent(List csvEntry) { - this( - csvEntry.get(0), - csvEntry.get(1) - ); - } - /** - * Default Dependent constructor - */ - public Dependent(String firstName, String lastName) { - this.firstName = firstName; - this.lastName = lastName; - } + /** + * + */ + public Dependent() { + super(); + } + /** + * constructor based on an entry in a CSV + * @param csvEntry + */ + public Dependent(List csvEntry) { + this( + csvEntry.get(0), + csvEntry.get(1) + ); + } + /** + * Default Dependent constructor + */ + public Dependent(String firstName, String lastName) { + this.firstName = firstName; + this.lastName = lastName; + } - /** - * Builder constructor - * @param builder - */ - public Dependent(Builder builder) { - this(builder.firstName, builder.lastName); - } + /** + * Builder constructor + * @param builder + */ + public Dependent(Builder builder) { + this(builder.firstName, builder.lastName); + } - /** - * Returns value of firstName - * @return - */ - public String getFirstName() { - return firstName; - } + /** + * Returns value of firstName + * @return + */ + public String getFirstName() { + return firstName; + } - /** - * Sets new value of firstName - * @param - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } + /** + * Sets new value of firstName + * @param + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } - /** - * Returns value of lastName - * @return - */ - public String getLastName() { - return lastName; - } + /** + * Returns value of lastName + * @return + */ + public String getLastName() { + return lastName; + } - /** - * Sets new value of lastName - * @param - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } + /** + * Sets new value of lastName + * @param + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } - @Override - public String toString() { - return "Dependent{" + - "firstName='" + firstName + '\'' + - ", lastName='" + lastName + '\'' + - '}'; - } + @Override + public String toString() { + return "Dependent{" + + "firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + '}'; + } - public static class Builder { - private String firstName; - private String lastName; + public static class Builder { + private String firstName; + private String lastName; - public static Builder newBuilder() { - return new Builder(); - } + public static Builder newBuilder() { + return new Builder(); + } - public Builder firstName(String firstName) { - this.firstName = firstName; - return this; - } + public Builder firstName(String firstName) { + this.firstName = firstName; + return this; + } - public Builder lastName(String lastName) { - this.lastName = lastName; - return this; - } + public Builder lastName(String lastName) { + this.lastName = lastName; + return this; + } - public Dependent build() { - return new Dependent(this); - } - } + public Dependent build() { + return new Dependent(this); + } + } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Vendor.java b/src/main/java/sf/codingcompetition2020/structures/Vendor.java index 81eb554..4ac28bb 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Vendor.java +++ b/src/main/java/sf/codingcompetition2020/structures/Vendor.java @@ -3,151 +3,151 @@ import java.util.List; public class Vendor { - private int vendorId; - private String area; - private int vendorRating; - private boolean inScope; - - /** - * Default Vendor constructor - */ - public Vendor(int vendorId, String area, int vendorRating, boolean inScope) { - this.vendorId = vendorId; - this.area = area; - this.vendorRating = vendorRating; - this.inScope = inScope; - } - - /** - * constructor based on an entry in a CSV - * @param csvEntry - */ - public Vendor(List csvEntry) { - this( - Integer.parseInt(csvEntry.get(0)), - csvEntry.get(1), - Integer.parseInt(csvEntry.get(2)), - Boolean.parseBoolean(csvEntry.get(3))); - } - - /** - * Builder constructor - * @param builder - */ - public Vendor(Builder builder) { - this( - builder.vendorId, - builder.area, - builder.vendorRating, - builder.inScope); - } - - /** - * Returns value of vendorId - * @return - */ - public int getVendorId() { - return vendorId; - } - - /** - * Sets new value of vendorId - * @param - */ - public void setVendorId(int vendorId) { - this.vendorId = vendorId; - } - - /** - * Returns value of area - * @return - */ - public String getArea() { - return area; - } - - /** - * Sets new value of area - * @param - */ - public void setArea(String area) { - this.area = area; - } - - /** - * Returns value of vendorRating - * @return - */ - public int getVendorRating() { - return vendorRating; - } - - /** - * Sets new value of vendorRating - * @param - */ - public void setVendorRating(int vendorRating) { - this.vendorRating = vendorRating; - } - - /** - * Returns value of inScope - * @return - */ - public boolean isInScope() { - return inScope; - } - - /** - * Sets new value of inScope - * @param - */ - public void setInScope(boolean inScope) { - this.inScope = inScope; - } - - @Override - public String toString() { - return "Vendor{" + - "vendorId=" + vendorId + - ", area='" + area + '\'' + - ", vendorRating=" + vendorRating + - ", inScope=" + inScope + - '}'; - } - - public static class Builder { - private int vendorId; - private String area; - private int vendorRating; - private boolean inScope; - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder vendorId(int vendorId) { - this.vendorId = vendorId; - return this; - } - - public Builder area(String area) { - this.area = area; - return this; - } - - public Builder vendorRating(int vendorRating) { - this.vendorRating = vendorRating; - return this; - } - - public Builder inScope(boolean inScope) { - this.inScope = inScope; - return this; - } - - public Vendor build() { - return new Vendor(this); - } - } + private int vendorId; + private String area; + private int vendorRating; + private boolean inScope; + + /** + * Default Vendor constructor + */ + public Vendor(int vendorId, String area, int vendorRating, boolean inScope) { + this.vendorId = vendorId; + this.area = area; + this.vendorRating = vendorRating; + this.inScope = inScope; + } + + /** + * constructor based on an entry in a CSV + * @param csvEntry + */ + public Vendor(List csvEntry) { + this( + Integer.parseInt(csvEntry.get(0)), + csvEntry.get(1), + Integer.parseInt(csvEntry.get(2)), + Boolean.parseBoolean(csvEntry.get(3))); + } + + /** + * Builder constructor + * @param builder + */ + public Vendor(Builder builder) { + this( + builder.vendorId, + builder.area, + builder.vendorRating, + builder.inScope); + } + + /** + * Returns value of vendorId + * @return + */ + public int getVendorId() { + return vendorId; + } + + /** + * Sets new value of vendorId + * @param + */ + public void setVendorId(int vendorId) { + this.vendorId = vendorId; + } + + /** + * Returns value of area + * @return + */ + public String getArea() { + return area; + } + + /** + * Sets new value of area + * @param + */ + public void setArea(String area) { + this.area = area; + } + + /** + * Returns value of vendorRating + * @return + */ + public int getVendorRating() { + return vendorRating; + } + + /** + * Sets new value of vendorRating + * @param + */ + public void setVendorRating(int vendorRating) { + this.vendorRating = vendorRating; + } + + /** + * Returns value of inScope + * @return + */ + public boolean isInScope() { + return inScope; + } + + /** + * Sets new value of inScope + * @param + */ + public void setInScope(boolean inScope) { + this.inScope = inScope; + } + + @Override + public String toString() { + return "Vendor{" + + "vendorId=" + vendorId + + ", area='" + area + '\'' + + ", vendorRating=" + vendorRating + + ", inScope=" + inScope + + '}'; + } + + public static class Builder { + private int vendorId; + private String area; + private int vendorRating; + private boolean inScope; + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder vendorId(int vendorId) { + this.vendorId = vendorId; + return this; + } + + public Builder area(String area) { + this.area = area; + return this; + } + + public Builder vendorRating(int vendorRating) { + this.vendorRating = vendorRating; + return this; + } + + public Builder inScope(boolean inScope) { + this.inScope = inScope; + return this; + } + + public Vendor build() { + return new Vendor(this); + } + } } diff --git a/src/main/java/sf/codingcompetition2020/utilities/Pair.java b/src/main/java/sf/codingcompetition2020/utilities/Pair.java index 2c4610e..0ecef22 100644 --- a/src/main/java/sf/codingcompetition2020/utilities/Pair.java +++ b/src/main/java/sf/codingcompetition2020/utilities/Pair.java @@ -2,35 +2,35 @@ public class Pair { - private T value1; - private V value2; - - public Pair(T value1, V value2) { - this.value1 = value1; - this.value2 = value2; - } - - public T getValue1() { - return value1; - } - - public void setValue1(T value1) { - this.value1 = value1; - } - - public V getValue2() { - return value2; - } - - public void setValue2(V value2) { - this.value2 = value2; - } - - @Override - public String toString() { - return "Pair{" + - "value1=" + value1 + - ", value2=" + value2 + - '}'; - } + private T value1; + private V value2; + + public Pair(T value1, V value2) { + this.value1 = value1; + this.value2 = value2; + } + + public T getValue1() { + return value1; + } + + public void setValue1(T value1) { + this.value1 = value1; + } + + public V getValue2() { + return value2; + } + + public void setValue2(V value2) { + this.value2 = value2; + } + + @Override + public String toString() { + return "Pair{" + + "value1=" + value1 + + ", value2=" + value2 + + '}'; + } } From 90752e0f092c1bf0408a582a19ff99bbe75b8764 Mon Sep 17 00:00:00 2001 From: mniverthi Date: Sun, 11 Oct 2020 00:55:06 -0400 Subject: [PATCH 22/26] added javadocs --- .../CodingCompCsvUtil.java | 144 +++++++++++------- .../CodingCompCsvUtilTest.java | 2 +- 2 files changed, 87 insertions(+), 59 deletions(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 244cb5f..f220d39 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -1,16 +1,14 @@ package sf.codingcompetition2020; - -import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.MappingIterator; -import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.dataformat.csv.CsvMapper; import com.fasterxml.jackson.dataformat.csv.CsvParser; -import com.fasterxml.jackson.dataformat.csv.CsvSchema; import java.io.File; import java.io.IOException; + import java.lang.reflect.InvocationTargetException; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -18,7 +16,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - import java.util.stream.Collectors; import sf.codingcompetition2020.structures.Agent; @@ -28,7 +25,7 @@ import sf.codingcompetition2020.utilities.Pair; /** - * This class processes CSV data related to Insurance policy data + * This class processes CSV data related to Insurance policy data. * @author Mudit Gupta * @author Manoj Niverthi * @version 1.2 @@ -37,40 +34,27 @@ public class CodingCompCsvUtil { /* #1 * readCsvFile() -- Read in a CSV File and return a list of entries in that file. - * @param filePath -- Path to file being read in. + * @param filePath-- Path to file being read in. * @param classType -- Class of entries being read in. * @return -- List of entries being returned. + * @throws IOException -- If file is interpreted incorrectly */ public List readCsvFile(String filePath, Class classType) throws IOException { - List interpretedFile = new ArrayList<>(); - - File csvFile = new File(filePath); - CsvMapper mapper = new CsvMapper(); - mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY); - MappingIterator it = mapper.readerFor(Object[].class).readValues(csvFile); - it.nextValue(); - it.forEachRemaining(row -> { - try { - interpretedFile.add(classType.getConstructor(List.class).newInstance(Arrays.asList(row))); - } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - } - }); - if (classType.equals(Customer.class)) { + List interpretedFile = new ArrayList<>(); - } -// FileReader fr = new FileReader(csvFile); -// BufferedReader br = new BufferedReader(fr); -// String entry; -// while ((entry = br.readLine()) != null) { -// List interpretedLine = Arrays.asList(entry.split("\\s*,\\s*")); -// try { -// interpretedFile.add(classType.getConstructor(List.class).newInstance(interpretedLine)); -// } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { -// e.printStackTrace(); -// } -// } - return interpretedFile; + File csvFile = new File(filePath); + CsvMapper mapper = new CsvMapper(); + mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY); + MappingIterator it = mapper.readerFor(Object[].class).readValues(csvFile); + it.nextValue(); + it.forEachRemaining(row -> { + try { + interpretedFile.add(classType.getConstructor(List.class).newInstance(Arrays.asList(row))); + } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + }); + return interpretedFile; } @@ -79,6 +63,7 @@ public List readCsvFile(String filePath, Class classType) throws IOExc * @param filePath -- Path to file being read in. * @param area -- The area from which the agents should be counted. * @return -- The number of agents in a given area + * @throws IOException -- If file is interpreted incorrectly */ public int getAgentCountInArea(String filePath, String area) throws IOException { return (int) readCsvFile(filePath, Agent.class).stream().filter(agent -> agent.getArea().equals(area)).count(); @@ -91,9 +76,13 @@ public int getAgentCountInArea(String filePath, String area) throws IOException * @param area -- The area from which the agents should be counted. * @param language -- The language spoken by the agent(s). * @return -- The number of agents in a given area + * @throws IOException -- If file is interpreted incorrectly */ - public List getAgentsInAreaThatSpeakLanguage(String filePath, String area, String language) throws IOException { - return readCsvFile(filePath, Agent.class).stream().filter(agent -> agent.getArea().equals(area) && agent.getLanguage().equals(language)).collect(Collectors.toList()); + public List getAgentsInAreaThatSpeakLanguage(String filePath, String area, + String language) throws IOException { + return readCsvFile(filePath, Agent.class).stream() + .filter(agent -> agent.getArea().equals(area) && agent.getLanguage().equals(language)) + .collect(Collectors.toList()); } @@ -104,21 +93,32 @@ public List getAgentsInAreaThatSpeakLanguage(String filePath, String area * @param agentFirstName -- First name of agent. * @param agentLastName -- Last name of agent. * @return -- The number of customers that use a certain agent in a given area. + * @throws IOException -- If file is interpreted incorrectly */ - public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, String customerArea, String agentFirstName, String agentLastName) throws IOException { - Agent desiredAgent = (Agent) readCsvFile(csvFilePaths.get("agentList"), Agent.class).stream().filter(agent -> agent.getFirstName().equals(agentFirstName) && agent.getLastName().equals(agentLastName)).toArray()[0]; - return (short) readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream().filter(customer -> customer.getArea().equals(customerArea) && customer.getAgentId() == desiredAgent.getAgentId()).count(); + public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, String customerArea, + String agentFirstName, String agentLastName) throws IOException { + Agent desiredAgent = (Agent) readCsvFile(csvFilePaths.get("agentList"), Agent.class).stream() + .filter(agent -> agent.getFirstName().equals(agentFirstName) && agent.getLastName() + .equals(agentLastName)).toArray()[0]; + return (short) readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream() + .filter(customer -> customer.getArea() + .equals(customerArea) && customer.getAgentId() == desiredAgent.getAgentId()).count(); } /* #5 - * getCustomersRetainedForYearsByPlcyCostAsc() -- Return a list of customers retained for a given number of years, in ascending order of their policy cost. + * getCustomersRetainedForYearsByPlcyCostAsc() -- Return a list of customers retained for a given number of years, + * in ascending order of their policy cost. * @param filePath -- Path to file being read in. * @param yearsOfServeice -- Number of years the person has been a customer. * @return -- List of customers retained for a given number of years, in ascending order of policy cost. + * @throws IOException -- If file is interpreted incorrectly */ - public List getCustomersRetainedForYearsByPlcyCostAsc(String customerFilePath, short yearsOfService) throws IOException { - return readCsvFile(customerFilePath, Customer.class).stream().filter(customer -> customer.getYearsOfService() == yearsOfService).sorted(Comparator.comparingInt(Customer::getTotalMonthlyPremium)).collect(Collectors.toList()); + public List getCustomersRetainedForYearsByPlcyCostAsc(String customerFilePath, + short yearsOfService) throws IOException { + return readCsvFile(customerFilePath, Customer.class).stream() + .filter(customer -> customer.getYearsOfService() == yearsOfService) + .sorted(Comparator.comparingInt(Customer::getTotalMonthlyPremium)).collect(Collectors.toList()); } @@ -127,24 +127,34 @@ public List getCustomersRetainedForYearsByPlcyCostAsc(String customerF * *HINT* -- Look for customers that currently have no policies with the insurance company. * @param filePath -- Path to file being read in. * @return -- List of customers who’ve made an inquiry for a policy but have not signed up. + * @throws IOException -- If file is interpreted incorrectly */ public List getLeadsForInsurance(String filePath) throws IOException { - return readCsvFile(filePath, Customer.class).stream().filter(customer -> !customer.hasAutoPolicy() && !customer.hasHomePolicy() && !customer.hasRentersPolicy()).collect(Collectors.toList()); + return readCsvFile(filePath, Customer.class).stream() + .filter(customer -> !customer.hasAutoPolicy() && !customer.hasHomePolicy() && !customer.hasRentersPolicy()) + .collect(Collectors.toList()); } /* #7 - * getVendorsWithGivenRatingThatAreInScope() -- Return a list of vendors within an area and include options to narrow it down by: + * getVendorsWithGivenRatingThatAreInScope() -- Return a list of vendors within an + * area and include options to narrow it down by: a. Vendor rating - b. Whether that vendor is in scope of the insurance (if inScope == false, return all vendors in OR out of scope, if inScope == true, return ONLY vendors in scope) + b. Whether that vendor is in scope of the insurance (if inScope == false, + * return all vendors in OR out of scope, if inScope == true, return ONLY vendors in scope) * @param filePath -- Path to file being read in. * @param area -- Area of the vendor. * @param inScope -- Whether or not the vendor is in scope of the insurance. * @param vendorRating -- The rating of the vendor. * @return -- List of vendors within a given area, filtered by scope and vendor rating. + * @throws IOException -- If file is interpreted incorrectly */ - public List getVendorsWithGivenRatingThatAreInScope(String filePath, String area, boolean inScope, int vendorRating) throws IOException { - return readCsvFile(filePath, Vendor.class).stream().filter(vendor -> vendor.getArea().equals(area) && vendor.getVendorRating() >= vendorRating && (!inScope || vendor.isInScope())).collect(Collectors.toList()); + public List getVendorsWithGivenRatingThatAreInScope(String filePath, String area, boolean inScope, + int vendorRating) throws IOException { + return readCsvFile(filePath, Vendor.class).stream() + .filter(vendor -> vendor.getArea().equals(area) + && vendor.getVendorRating() >= vendorRating && (!inScope || vendor.isInScope())) + .collect(Collectors.toList()); } @@ -156,19 +166,24 @@ public List getVendorsWithGivenRatingThatAreInScope(String filePath, Str * @param vehiclesInsured -- The number of vehicles insured. * @param dependents -- The number of dependents on the insurance policy. * @return -- List of customers filtered by age, number of vehicles insured and the number of dependents. + * @throws IOException -- If file is interpreted incorrectly */ public List getUndisclosedDrivers(String filePath, int vehiclesInsured, int dependents) throws IOException { - return readCsvFile(filePath, Customer.class).stream().filter(customer -> customer.getAge() >= 40 && customer.getAge() <= 50 && customer.getVehiclesInsured() > vehiclesInsured && customer.getDependents().size() <= dependents).collect(Collectors.toList()); + return readCsvFile(filePath, Customer.class).stream() + .filter(customer -> customer.getAge() >= 40 && customer.getAge() <= 50 + && customer.getVehiclesInsured() > vehiclesInsured && customer.getDependents().size() <= dependents) + .collect(Collectors.toList()); } /* #9 * getAgentIdGivenRank() -- Return the agent with the given rank based on average customer satisfaction rating. - * *HINT* -- Rating is calculated by taking all the agent rating by customers (1-5 scale) and dividing by the total number - * of reviews for the agent. + * *HINT* -- Rating is calculated by taking all the agent rating by customers (1-5 scale) + * and dividing by the total number of reviews for the agent. * @param filePath -- Path to file being read in. * @param agentRank -- The rank of the agent being requested. * @return -- Agent ID of agent with the given rank. + * @throws IOException -- If file is interpreted incorrectly */ public int getAgentIdGivenRank(String filePath, int agentRank) throws IOException { List allCustomers = readCsvFile(filePath, Customer.class); @@ -213,21 +228,29 @@ public int getAgentIdGivenRank(String filePath, int agentRank) throws IOExceptio /* #10 - * getCustomersWithClaims() -- Return a list of customers who’ve filed a claim within the last (inclusive). + * getCustomersWithClaims() -- Return a list of customers who’ve filed a claim within the last + * (inclusive). * @param filePath -- Path to file being read in. * @param monthsOpen -- Number of months a policy has been open. * @return -- List of customers who’ve filed a claim within the last . + * @throws IOException -- If file is interpreted incorrectly */ public List getCustomersWithClaims(Map csvFilePaths, short monthsOpen) throws IOException { - List customerIDsWithRecentClaim = readCsvFile(csvFilePaths.get("claimList"), Claim.class).stream().filter(claim -> claim.getMonthsOpen() <= monthsOpen).map(claim -> claim.getCustomerId()).collect(Collectors.toList()); - return readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream().filter(customer -> customerIDsWithRecentClaim.contains(customer.getCustomerId())).collect(Collectors.toList()); + List customerIDsWithRecentClaim = readCsvFile(csvFilePaths.get("claimList"), Claim.class).stream() + .filter(claim -> claim.getMonthsOpen() <= monthsOpen).map(claim -> claim.getCustomerId()) + .collect(Collectors.toList()); + return readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream() + .filter(customer -> customerIDsWithRecentClaim.contains(customer.getCustomerId())) + .collect(Collectors.toList()); } /* Custom methods: 1 - * getCustomersBasedOnNumberOfPolicies() -- Return a list of customers who have policies (inclusive). + * getCustomersBasedOnNumberOfPolicies() -- Return a list of customers who have + * policies (inclusive). * @param filePath -- Path to file being read in. * @param numberOfPolicies -- Number of months a policy has been open. * @return -- List of customers who have policies. + * @throws IOException -- If file is interpreted incorrectly */ public List getCustomersBasedOnNumberOfPolicies(String filePath, int numberOfPolicies) throws IOException { return readCsvFile(filePath, Customer.class).stream().filter(customer -> { @@ -251,9 +274,14 @@ public List getCustomersBasedOnNumberOfPolicies(String filePath, int n * @param customerFirstName -- last name of customer * @param customerLastName -- first name of customer * @return -- list of vendors that operate in the area of a given customer + * @throws IOException -- If file is interpreted incorrectly */ - public List getVendorsForCustomerBasedOnArea(Map csvFilePaths, String customerFirstName, String customerLastName) throws IOException { - String desiredArea = readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream().filter(customer -> customer.getFirstName().equals(customerFirstName) && customer.getLastName().equals(customerLastName)).iterator().next().getArea(); - return readCsvFile(csvFilePaths.get("vendorFilePath"), Vendor.class).stream().filter(vendor -> vendor.getArea().equals(desiredArea)).collect(Collectors.toList()); + public List getVendorsForCustomerBasedOnArea(Map csvFilePaths, String customerFirstName, + String customerLastName) throws IOException { + String desiredArea = readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream() + .filter(customer -> customer.getFirstName().equals(customerFirstName) && customer.getLastName() + .equals(customerLastName)).iterator().next().getArea(); + return readCsvFile(csvFilePaths.get("vendorList"), Vendor.class).stream() + .filter(vendor -> vendor.getArea().equals(desiredArea)).collect(Collectors.toList()); } } diff --git a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java index b72cb0d..eefabcf 100644 --- a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java +++ b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java @@ -137,7 +137,7 @@ public void getVendorsForCustomerBasedOnArea() throws IOException { csvFilePaths.put(customerList, customerFilePath); csvFilePaths.put(vendorList, vendorFilePath); List result = codingCompCsVUtil.getVendorsForCustomerBasedOnArea(csvFilePaths, "Alexine", "Spinella"); - + assertEquals(52, result.size()); assertEquals(1, result.get(0).getVendorId()); assertTrue(result.get(0).isInScope()); From d0dd2ec94b3e234bc76e720a8fb39f80d867ab1b Mon Sep 17 00:00:00 2001 From: mniverthi Date: Sun, 11 Oct 2020 00:55:18 -0400 Subject: [PATCH 23/26] added javadocs --- src/main/java/javadocs/allclasses-frame.html | 19 + .../java/javadocs/allclasses-noframe.html | 19 + src/main/java/javadocs/constant-values.html | 120 ++++ src/main/java/javadocs/deprecated-list.html | 120 ++++ src/main/java/javadocs/help-doc.html | 217 +++++++ src/main/java/javadocs/index-all.html | 177 ++++++ src/main/java/javadocs/index.html | 72 +++ src/main/java/javadocs/overview-tree.html | 133 ++++ src/main/java/javadocs/package-list | 1 + src/main/java/javadocs/script.js | 30 + .../CodingCompCsvUtil.html | 525 ++++++++++++++++ .../codingcompetition2020/package-frame.html | 20 + .../package-summary.html | 140 +++++ .../codingcompetition2020/package-tree.html | 129 ++++ src/main/java/javadocs/stylesheet.css | 574 ++++++++++++++++++ 15 files changed, 2296 insertions(+) create mode 100644 src/main/java/javadocs/allclasses-frame.html create mode 100644 src/main/java/javadocs/allclasses-noframe.html create mode 100644 src/main/java/javadocs/constant-values.html create mode 100644 src/main/java/javadocs/deprecated-list.html create mode 100644 src/main/java/javadocs/help-doc.html create mode 100644 src/main/java/javadocs/index-all.html create mode 100644 src/main/java/javadocs/index.html create mode 100644 src/main/java/javadocs/overview-tree.html create mode 100644 src/main/java/javadocs/package-list create mode 100644 src/main/java/javadocs/script.js create mode 100644 src/main/java/javadocs/sf/codingcompetition2020/CodingCompCsvUtil.html create mode 100644 src/main/java/javadocs/sf/codingcompetition2020/package-frame.html create mode 100644 src/main/java/javadocs/sf/codingcompetition2020/package-summary.html create mode 100644 src/main/java/javadocs/sf/codingcompetition2020/package-tree.html create mode 100644 src/main/java/javadocs/stylesheet.css diff --git a/src/main/java/javadocs/allclasses-frame.html b/src/main/java/javadocs/allclasses-frame.html new file mode 100644 index 0000000..9e0937b --- /dev/null +++ b/src/main/java/javadocs/allclasses-frame.html @@ -0,0 +1,19 @@ + + + + + +All Classes + + + + + +

All Classes

+ + + diff --git a/src/main/java/javadocs/allclasses-noframe.html b/src/main/java/javadocs/allclasses-noframe.html new file mode 100644 index 0000000..9a3cc03 --- /dev/null +++ b/src/main/java/javadocs/allclasses-noframe.html @@ -0,0 +1,19 @@ + + + + + +All Classes + + + + + +

All Classes

+ + + diff --git a/src/main/java/javadocs/constant-values.html b/src/main/java/javadocs/constant-values.html new file mode 100644 index 0000000..8c76a1b --- /dev/null +++ b/src/main/java/javadocs/constant-values.html @@ -0,0 +1,120 @@ + + + + + +Constant Field Values + + + + + + + + + + + +
+

Constant Field Values

+

Contents

+
+ + + + + + diff --git a/src/main/java/javadocs/deprecated-list.html b/src/main/java/javadocs/deprecated-list.html new file mode 100644 index 0000000..7408fbc --- /dev/null +++ b/src/main/java/javadocs/deprecated-list.html @@ -0,0 +1,120 @@ + + + + + +Deprecated List + + + + + + + + +
+ + + + + + + +
+ + +
+

Deprecated API

+

Contents

+
+ +
+ + + + + + + +
+ + + + diff --git a/src/main/java/javadocs/help-doc.html b/src/main/java/javadocs/help-doc.html new file mode 100644 index 0000000..c38a898 --- /dev/null +++ b/src/main/java/javadocs/help-doc.html @@ -0,0 +1,217 @@ + + + + + +API Help + + + + + + + + + + + +
+

How This API Document Is Organized

+
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+
+
+
    +
  • +

    Package

    +

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    +
      +
    • Interfaces (italic)
    • +
    • Classes
    • +
    • Enums
    • +
    • Exceptions
    • +
    • Errors
    • +
    • Annotation Types
    • +
    +
  • +
  • +

    Class/Interface

    +

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    +
      +
    • Class inheritance diagram
    • +
    • Direct Subclasses
    • +
    • All Known Subinterfaces
    • +
    • All Known Implementing Classes
    • +
    • Class/interface declaration
    • +
    • Class/interface description
    • +
    +
      +
    • Nested Class Summary
    • +
    • Field Summary
    • +
    • Constructor Summary
    • +
    • Method Summary
    • +
    +
      +
    • Field Detail
    • +
    • Constructor Detail
    • +
    • Method Detail
    • +
    +

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

    +
  • +
  • +

    Annotation Type

    +

    Each annotation type has its own separate page with the following sections:

    +
      +
    • Annotation Type declaration
    • +
    • Annotation Type description
    • +
    • Required Element Summary
    • +
    • Optional Element Summary
    • +
    • Element Detail
    • +
    +
  • +
  • +

    Enum

    +

    Each enum has its own separate page with the following sections:

    +
      +
    • Enum declaration
    • +
    • Enum description
    • +
    • Enum Constant Summary
    • +
    • Enum Constant Detail
    • +
    +
  • +
  • +

    Tree (Class Hierarchy)

    +

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

    +
      +
    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • +
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
    • +
    +
  • +
  • +

    Deprecated API

    +

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

    +
  • +
  • +

    Index

    +

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

    +
  • +
  • +

    Prev/Next

    +

    These links take you to the next or previous class, interface, package, or related page.

    +
  • +
  • +

    Frames/No Frames

    +

    These links show and hide the HTML frames. All pages are available with or without frames.

    +
  • +
  • +

    All Classes

    +

    The All Classes link shows all classes and interfaces except non-static nested types.

    +
  • +
  • +

    Serialized Form

    +

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

    +
  • +
  • +

    Constant Field Values

    +

    The Constant Field Values page lists the static final fields and their values.

    +
  • +
+This help file applies to API documentation generated using the standard doclet.
+ + + + + + diff --git a/src/main/java/javadocs/index-all.html b/src/main/java/javadocs/index-all.html new file mode 100644 index 0000000..dde02a7 --- /dev/null +++ b/src/main/java/javadocs/index-all.html @@ -0,0 +1,177 @@ + + + + + +Index + + + + + + + + + + + +
C G R S  + + +

C

+
+
CodingCompCsvUtil - Class in sf.codingcompetition2020
+
+
This class processes CSV data related to Insurance policy data.
+
+
CodingCompCsvUtil() - Constructor for class sf.codingcompetition2020.CodingCompCsvUtil
+
 
+
countCustomersFromAreaThatUseAgent(Map<String, String>, String, String, String) - Method in class sf.codingcompetition2020.CodingCompCsvUtil
+
 
+
+ + + +

G

+
+
getAgentCountInArea(String, String) - Method in class sf.codingcompetition2020.CodingCompCsvUtil
+
+
Return the number of agents in a given area.
+
+
getAgentIdGivenRank(String, int) - Method in class sf.codingcompetition2020.CodingCompCsvUtil
+
 
+
getAgentsInAreaThatSpeakLanguage(String, String, String) - Method in class sf.codingcompetition2020.CodingCompCsvUtil
+
 
+
getCustomersBasedOnNumberOfPolicies(String, int) - Method in class sf.codingcompetition2020.CodingCompCsvUtil
+
 
+
getCustomersRetainedForYearsByPlcyCostAsc(String, short) - Method in class sf.codingcompetition2020.CodingCompCsvUtil
+
 
+
getCustomersWithClaims(Map<String, String>, short) - Method in class sf.codingcompetition2020.CodingCompCsvUtil
+
 
+
getLeadsForInsurance(String) - Method in class sf.codingcompetition2020.CodingCompCsvUtil
+
 
+
getUndisclosedDrivers(String, int, int) - Method in class sf.codingcompetition2020.CodingCompCsvUtil
+
 
+
getVendorsForCustomerBasedOnArea(Map<String, String>, String, String) - Method in class sf.codingcompetition2020.CodingCompCsvUtil
+
 
+
getVendorsWithGivenRatingThatAreInScope(String, String, boolean, int) - Method in class sf.codingcompetition2020.CodingCompCsvUtil
+
 
+
+ + + +

R

+
+
readCsvFile(String, Class<T>) - Method in class sf.codingcompetition2020.CodingCompCsvUtil
+
+
Read in a CSV File and return a list of entries in that file.
+
+
+ + + +

S

+
+
sf.codingcompetition2020 - package sf.codingcompetition2020
+
 
+
+C G R S 
+ + + + + + diff --git a/src/main/java/javadocs/index.html b/src/main/java/javadocs/index.html new file mode 100644 index 0000000..f7a0427 --- /dev/null +++ b/src/main/java/javadocs/index.html @@ -0,0 +1,72 @@ + + + + + +Generated Documentation (Untitled) + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="sf/codingcompetition2020/package-summary.html">Non-frame version</a>.</p> + + + diff --git a/src/main/java/javadocs/overview-tree.html b/src/main/java/javadocs/overview-tree.html new file mode 100644 index 0000000..e264aa2 --- /dev/null +++ b/src/main/java/javadocs/overview-tree.html @@ -0,0 +1,133 @@ + + + + + +Class Hierarchy + + + + + + + + + + + +
+

Hierarchy For All Packages

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ + + + + + diff --git a/src/main/java/javadocs/package-list b/src/main/java/javadocs/package-list new file mode 100644 index 0000000..bb3c9f5 --- /dev/null +++ b/src/main/java/javadocs/package-list @@ -0,0 +1 @@ +sf.codingcompetition2020 diff --git a/src/main/java/javadocs/script.js b/src/main/java/javadocs/script.js new file mode 100644 index 0000000..b346356 --- /dev/null +++ b/src/main/java/javadocs/script.js @@ -0,0 +1,30 @@ +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff --git a/src/main/java/javadocs/sf/codingcompetition2020/CodingCompCsvUtil.html b/src/main/java/javadocs/sf/codingcompetition2020/CodingCompCsvUtil.html new file mode 100644 index 0000000..ac57e1a --- /dev/null +++ b/src/main/java/javadocs/sf/codingcompetition2020/CodingCompCsvUtil.html @@ -0,0 +1,525 @@ + + + + + +CodingCompCsvUtil + + + + + + + + + + + + +
+
sf.codingcompetition2020
+

Class CodingCompCsvUtil

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • sf.codingcompetition2020.CodingCompCsvUtil
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class CodingCompCsvUtil
    +extends java.lang.Object
    +
    This class processes CSV data related to Insurance policy data.
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      CodingCompCsvUtil() 
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      shortcountCustomersFromAreaThatUseAgent(java.util.Map<java.lang.String,java.lang.String> csvFilePaths, + java.lang.String customerArea, + java.lang.String agentFirstName, + java.lang.String agentLastName) 
      intgetAgentCountInArea(java.lang.String filePath, + java.lang.String area) +
      Return the number of agents in a given area.
      +
      intgetAgentIdGivenRank(java.lang.String filePath, + int agentRank) 
      java.util.List<sf.codingcompetition2020.structures.Agent>getAgentsInAreaThatSpeakLanguage(java.lang.String filePath, + java.lang.String area, + java.lang.String language) 
      java.util.List<sf.codingcompetition2020.structures.Customer>getCustomersBasedOnNumberOfPolicies(java.lang.String filePath, + int numberOfPolicies) 
      java.util.List<sf.codingcompetition2020.structures.Customer>getCustomersRetainedForYearsByPlcyCostAsc(java.lang.String customerFilePath, + short yearsOfService) 
      java.util.List<sf.codingcompetition2020.structures.Customer>getCustomersWithClaims(java.util.Map<java.lang.String,java.lang.String> csvFilePaths, + short monthsOpen) 
      java.util.List<sf.codingcompetition2020.structures.Customer>getLeadsForInsurance(java.lang.String filePath) 
      java.util.List<sf.codingcompetition2020.structures.Customer>getUndisclosedDrivers(java.lang.String filePath, + int vehiclesInsured, + int dependents) 
      java.util.List<sf.codingcompetition2020.structures.Vendor>getVendorsForCustomerBasedOnArea(java.util.Map<java.lang.String,java.lang.String> csvFilePaths, + java.lang.String customerFirstName, + java.lang.String customerLastName) 
      java.util.List<sf.codingcompetition2020.structures.Vendor>getVendorsWithGivenRatingThatAreInScope(java.lang.String filePath, + java.lang.String area, + boolean inScope, + int vendorRating) 
      <T> java.util.List<T>readCsvFile(java.lang.String filePath, + java.lang.Class<T> classType) +
      Read in a CSV File and return a list of entries in that file.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        CodingCompCsvUtil

        +
        public CodingCompCsvUtil()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        readCsvFile

        +
        public <T> java.util.List<T> readCsvFile(java.lang.String filePath,
        +                                         java.lang.Class<T> classType)
        +                                  throws java.io.IOException
        +
        Read in a CSV File and return a list of entries in that file.
        +
        +
        Type Parameters:
        +
        T - Type of Object to parse
        +
        Parameters:
        +
        filePath - Path to file being read in.
        +
        classType - Class of entries being read in.
        +
        Returns:
        +
        List of entries being returned.
        +
        Throws:
        +
        java.io.IOException
        +
        +
      • +
      + + + +
        +
      • +

        getAgentCountInArea

        +
        public int getAgentCountInArea(java.lang.String filePath,
        +                               java.lang.String area)
        +                        throws java.io.IOException
        +
        Return the number of agents in a given area.
        +
        +
        Parameters:
        +
        filePath - Path to file being read in.
        +
        area - The area from which the agents should be counted.
        +
        Returns:
        +
        The number of agents in a given area
        +
        Throws:
        +
        java.io.IOException - If file is interpreted incorrectly
        +
        +
      • +
      + + + +
        +
      • +

        getAgentsInAreaThatSpeakLanguage

        +
        public java.util.List<sf.codingcompetition2020.structures.Agent> getAgentsInAreaThatSpeakLanguage(java.lang.String filePath,
        +                                                                                                  java.lang.String area,
        +                                                                                                  java.lang.String language)
        +                                                                                           throws java.io.IOException
        +
        +
        Throws:
        +
        java.io.IOException
        +
        +
      • +
      + + + +
        +
      • +

        countCustomersFromAreaThatUseAgent

        +
        public short countCustomersFromAreaThatUseAgent(java.util.Map<java.lang.String,java.lang.String> csvFilePaths,
        +                                                java.lang.String customerArea,
        +                                                java.lang.String agentFirstName,
        +                                                java.lang.String agentLastName)
        +                                         throws java.io.IOException
        +
        +
        Throws:
        +
        java.io.IOException
        +
        +
      • +
      + + + +
        +
      • +

        getCustomersRetainedForYearsByPlcyCostAsc

        +
        public java.util.List<sf.codingcompetition2020.structures.Customer> getCustomersRetainedForYearsByPlcyCostAsc(java.lang.String customerFilePath,
        +                                                                                                              short yearsOfService)
        +                                                                                                       throws java.io.IOException
        +
        +
        Throws:
        +
        java.io.IOException
        +
        +
      • +
      + + + +
        +
      • +

        getLeadsForInsurance

        +
        public java.util.List<sf.codingcompetition2020.structures.Customer> getLeadsForInsurance(java.lang.String filePath)
        +                                                                                  throws java.io.IOException
        +
        +
        Throws:
        +
        java.io.IOException
        +
        +
      • +
      + + + +
        +
      • +

        getVendorsWithGivenRatingThatAreInScope

        +
        public java.util.List<sf.codingcompetition2020.structures.Vendor> getVendorsWithGivenRatingThatAreInScope(java.lang.String filePath,
        +                                                                                                          java.lang.String area,
        +                                                                                                          boolean inScope,
        +                                                                                                          int vendorRating)
        +                                                                                                   throws java.io.IOException
        +
        +
        Throws:
        +
        java.io.IOException
        +
        +
      • +
      + + + +
        +
      • +

        getUndisclosedDrivers

        +
        public java.util.List<sf.codingcompetition2020.structures.Customer> getUndisclosedDrivers(java.lang.String filePath,
        +                                                                                          int vehiclesInsured,
        +                                                                                          int dependents)
        +                                                                                   throws java.io.IOException
        +
        +
        Throws:
        +
        java.io.IOException
        +
        +
      • +
      + + + +
        +
      • +

        getAgentIdGivenRank

        +
        public int getAgentIdGivenRank(java.lang.String filePath,
        +                               int agentRank)
        +                        throws java.io.IOException
        +
        +
        Throws:
        +
        java.io.IOException
        +
        +
      • +
      + + + +
        +
      • +

        getCustomersWithClaims

        +
        public java.util.List<sf.codingcompetition2020.structures.Customer> getCustomersWithClaims(java.util.Map<java.lang.String,java.lang.String> csvFilePaths,
        +                                                                                           short monthsOpen)
        +                                                                                    throws java.io.IOException
        +
        +
        Throws:
        +
        java.io.IOException
        +
        +
      • +
      + + + +
        +
      • +

        getCustomersBasedOnNumberOfPolicies

        +
        public java.util.List<sf.codingcompetition2020.structures.Customer> getCustomersBasedOnNumberOfPolicies(java.lang.String filePath,
        +                                                                                                        int numberOfPolicies)
        +                                                                                                 throws java.io.IOException
        +
        +
        Throws:
        +
        java.io.IOException
        +
        +
      • +
      + + + +
        +
      • +

        getVendorsForCustomerBasedOnArea

        +
        public java.util.List<sf.codingcompetition2020.structures.Vendor> getVendorsForCustomerBasedOnArea(java.util.Map<java.lang.String,java.lang.String> csvFilePaths,
        +                                                                                                   java.lang.String customerFirstName,
        +                                                                                                   java.lang.String customerLastName)
        +                                                                                            throws java.io.IOException
        +
        +
        Throws:
        +
        java.io.IOException
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/src/main/java/javadocs/sf/codingcompetition2020/package-frame.html b/src/main/java/javadocs/sf/codingcompetition2020/package-frame.html new file mode 100644 index 0000000..4413f5a --- /dev/null +++ b/src/main/java/javadocs/sf/codingcompetition2020/package-frame.html @@ -0,0 +1,20 @@ + + + + + +sf.codingcompetition2020 + + + + + +

sf.codingcompetition2020

+
+

Classes

+ +
+ + diff --git a/src/main/java/javadocs/sf/codingcompetition2020/package-summary.html b/src/main/java/javadocs/sf/codingcompetition2020/package-summary.html new file mode 100644 index 0000000..711ec1b --- /dev/null +++ b/src/main/java/javadocs/sf/codingcompetition2020/package-summary.html @@ -0,0 +1,140 @@ + + + + + +sf.codingcompetition2020 + + + + + + + + + + + +
+

Package sf.codingcompetition2020

+
+
+
    +
  • + + + + + + + + + + + + +
    Class Summary 
    ClassDescription
    CodingCompCsvUtil +
    This class processes CSV data related to Insurance policy data.
    +
    +
  • +
+
+ + + + + + diff --git a/src/main/java/javadocs/sf/codingcompetition2020/package-tree.html b/src/main/java/javadocs/sf/codingcompetition2020/package-tree.html new file mode 100644 index 0000000..236a00a --- /dev/null +++ b/src/main/java/javadocs/sf/codingcompetition2020/package-tree.html @@ -0,0 +1,129 @@ + + + + + +sf.codingcompetition2020 Class Hierarchy + + + + + + + + + + + +
+

Hierarchy For Package sf.codingcompetition2020

+
+
+

Class Hierarchy

+ +
+ + + + + + diff --git a/src/main/java/javadocs/stylesheet.css b/src/main/java/javadocs/stylesheet.css new file mode 100644 index 0000000..98055b2 --- /dev/null +++ b/src/main/java/javadocs/stylesheet.css @@ -0,0 +1,574 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ + +@import url('resources/fonts/dejavu.css'); + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4A6782; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.subNavList li{ + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor { + background-color:#FFFFFF; +} +.rowColor { + background-color:#EEEEEF; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +div.contentContainer ul.blockList li.blockList h2{ + padding-bottom:0px; +} From 4e8239bc21d0799ca001dc65ba5a8edac7aa90fa Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 11 Oct 2020 00:55:36 -0400 Subject: [PATCH 24/26] update feedback --- feedback.txt | 12 +++++++++++- .../sf/codingcompetition2020/CodingCompCsvUtil.java | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/feedback.txt b/feedback.txt index 5a1adc6..60510a8 100644 --- a/feedback.txt +++ b/feedback.txt @@ -10,7 +10,17 @@ Document and describe any enhancements included to help the judges properly grad Step 4: The Customer class was using a String for the totalMonthlyPremium because of a dollar sign, so we converted it to an int. This makes future use of the value much more intuitive and meaningful. We also updated the test values in the JUnit to reflect the better implementation. - Step 5: + Step 5: We improved the javadocs for all of the provided methods to make their use easier. + We also generated the javadoc HTML for this project, so that they can be more easily referenced. + Step 6: We created 2 methods in the CsvUtil class that can be used to find other patterns in the data. + We created getCustomersBasedOnNumberOfPolicies and getVendorsForCustomerBasedOnArea. + We also created tests for these two methods. + Step 7: We implemented the Builder pattern for each of the data classes. Although unused for this implementation, builders are a very helpful design pattern to use when a constructor has many hard-to-remember parameters. + If a user wanted to add functionality for creating objects and writing to CSV, rather than reading, the builder would prove very valuable for code readability/maintainability. Feedback for the coding competition? Things you would like to see in future events? +Some of the requirements in the javadocs wre a bit unclear. + For #5, we had to do customer.getYearsOfService() == yearsOfService + But for #7, we had to do vendor.getVendorRating() >= vendorRating + Whether or not we use > or == was a bit unclear and required us to guess as to why the tests failed. \ No newline at end of file diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 244cb5f..4be9f16 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -223,7 +223,7 @@ public List getCustomersWithClaims(Map csvFilePaths, s return readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream().filter(customer -> customerIDsWithRecentClaim.contains(customer.getCustomerId())).collect(Collectors.toList()); } - /* Custom methods: 1 + /* Custom method #1 * getCustomersBasedOnNumberOfPolicies() -- Return a list of customers who have policies (inclusive). * @param filePath -- Path to file being read in. * @param numberOfPolicies -- Number of months a policy has been open. @@ -245,7 +245,7 @@ public List getCustomersBasedOnNumberOfPolicies(String filePath, int n }).collect(Collectors.toList()); } - /* Custom methods: 2 + /* Custom methods #2 * getVendorsForCustomerBasedOnArea() -- Return a list of vendors that operate in the area of a given customer. * @param csvFilePaths -- Paths to files being read in. * @param customerFirstName -- last name of customer From 32630cca4bbfbed5d8e9d41d371e7b1a4ba44318 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 11 Oct 2020 00:58:10 -0400 Subject: [PATCH 25/26] fedback --- feedback.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feedback.txt b/feedback.txt index 60510a8..40f39c6 100644 --- a/feedback.txt +++ b/feedback.txt @@ -11,7 +11,7 @@ Document and describe any enhancements included to help the judges properly grad This makes future use of the value much more intuitive and meaningful. We also updated the test values in the JUnit to reflect the better implementation. Step 5: We improved the javadocs for all of the provided methods to make their use easier. - We also generated the javadoc HTML for this project, so that they can be more easily referenced. + We also generated the javadoc HTML for this project, so that they can be more easily referenced. These can be found in src/main/java/javadocs/index.html Step 6: We created 2 methods in the CsvUtil class that can be used to find other patterns in the data. We created getCustomersBasedOnNumberOfPolicies and getVendorsForCustomerBasedOnArea. We also created tests for these two methods. From 14483bd4ef859b0ae64c214db632174abc904809 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 11 Oct 2020 00:59:17 -0400 Subject: [PATCH 26/26] move javadocs --- feedback.txt | 2 +- {src/main/java/javadocs => javadocs}/allclasses-frame.html | 0 .../main/java/javadocs => javadocs}/allclasses-noframe.html | 0 {src/main/java/javadocs => javadocs}/constant-values.html | 0 {src/main/java/javadocs => javadocs}/deprecated-list.html | 0 {src/main/java/javadocs => javadocs}/help-doc.html | 0 {src/main/java/javadocs => javadocs}/index-all.html | 0 {src/main/java/javadocs => javadocs}/index.html | 0 {src/main/java/javadocs => javadocs}/overview-tree.html | 0 {src/main/java/javadocs => javadocs}/package-list | 0 {src/main/java/javadocs => javadocs}/script.js | 0 .../sf/codingcompetition2020/CodingCompCsvUtil.html | 4 ++-- .../sf/codingcompetition2020/package-frame.html | 2 +- .../sf/codingcompetition2020/package-summary.html | 2 +- .../sf/codingcompetition2020/package-tree.html | 6 +++--- {src/main/java/javadocs => javadocs}/stylesheet.css | 0 16 files changed, 8 insertions(+), 8 deletions(-) rename {src/main/java/javadocs => javadocs}/allclasses-frame.html (100%) rename {src/main/java/javadocs => javadocs}/allclasses-noframe.html (100%) rename {src/main/java/javadocs => javadocs}/constant-values.html (100%) rename {src/main/java/javadocs => javadocs}/deprecated-list.html (100%) rename {src/main/java/javadocs => javadocs}/help-doc.html (100%) rename {src/main/java/javadocs => javadocs}/index-all.html (100%) rename {src/main/java/javadocs => javadocs}/index.html (100%) rename {src/main/java/javadocs => javadocs}/overview-tree.html (100%) rename {src/main/java/javadocs => javadocs}/package-list (100%) rename {src/main/java/javadocs => javadocs}/script.js (100%) rename {src/main/java/javadocs => javadocs}/sf/codingcompetition2020/CodingCompCsvUtil.html (99%) rename {src/main/java/javadocs => javadocs}/sf/codingcompetition2020/package-frame.html (84%) rename {src/main/java/javadocs => javadocs}/sf/codingcompetition2020/package-summary.html (96%) rename {src/main/java/javadocs => javadocs}/sf/codingcompetition2020/package-tree.html (90%) rename {src/main/java/javadocs => javadocs}/stylesheet.css (100%) diff --git a/feedback.txt b/feedback.txt index 40f39c6..66886ca 100644 --- a/feedback.txt +++ b/feedback.txt @@ -11,7 +11,7 @@ Document and describe any enhancements included to help the judges properly grad This makes future use of the value much more intuitive and meaningful. We also updated the test values in the JUnit to reflect the better implementation. Step 5: We improved the javadocs for all of the provided methods to make their use easier. - We also generated the javadoc HTML for this project, so that they can be more easily referenced. These can be found in src/main/java/javadocs/index.html + We also generated the javadoc HTML for this project, so that they can be more easily referenced. These can be found in javadocs/index.html Step 6: We created 2 methods in the CsvUtil class that can be used to find other patterns in the data. We created getCustomersBasedOnNumberOfPolicies and getVendorsForCustomerBasedOnArea. We also created tests for these two methods. diff --git a/src/main/java/javadocs/allclasses-frame.html b/javadocs/allclasses-frame.html similarity index 100% rename from src/main/java/javadocs/allclasses-frame.html rename to javadocs/allclasses-frame.html diff --git a/src/main/java/javadocs/allclasses-noframe.html b/javadocs/allclasses-noframe.html similarity index 100% rename from src/main/java/javadocs/allclasses-noframe.html rename to javadocs/allclasses-noframe.html diff --git a/src/main/java/javadocs/constant-values.html b/javadocs/constant-values.html similarity index 100% rename from src/main/java/javadocs/constant-values.html rename to javadocs/constant-values.html diff --git a/src/main/java/javadocs/deprecated-list.html b/javadocs/deprecated-list.html similarity index 100% rename from src/main/java/javadocs/deprecated-list.html rename to javadocs/deprecated-list.html diff --git a/src/main/java/javadocs/help-doc.html b/javadocs/help-doc.html similarity index 100% rename from src/main/java/javadocs/help-doc.html rename to javadocs/help-doc.html diff --git a/src/main/java/javadocs/index-all.html b/javadocs/index-all.html similarity index 100% rename from src/main/java/javadocs/index-all.html rename to javadocs/index-all.html diff --git a/src/main/java/javadocs/index.html b/javadocs/index.html similarity index 100% rename from src/main/java/javadocs/index.html rename to javadocs/index.html diff --git a/src/main/java/javadocs/overview-tree.html b/javadocs/overview-tree.html similarity index 100% rename from src/main/java/javadocs/overview-tree.html rename to javadocs/overview-tree.html diff --git a/src/main/java/javadocs/package-list b/javadocs/package-list similarity index 100% rename from src/main/java/javadocs/package-list rename to javadocs/package-list diff --git a/src/main/java/javadocs/script.js b/javadocs/script.js similarity index 100% rename from src/main/java/javadocs/script.js rename to javadocs/script.js diff --git a/src/main/java/javadocs/sf/codingcompetition2020/CodingCompCsvUtil.html b/javadocs/sf/codingcompetition2020/CodingCompCsvUtil.html similarity index 99% rename from src/main/java/javadocs/sf/codingcompetition2020/CodingCompCsvUtil.html rename to javadocs/sf/codingcompetition2020/CodingCompCsvUtil.html index ac57e1a..67ce7f9 100644 --- a/src/main/java/javadocs/sf/codingcompetition2020/CodingCompCsvUtil.html +++ b/javadocs/sf/codingcompetition2020/CodingCompCsvUtil.html @@ -37,7 +37,7 @@