diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..0938c55
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+coding-competition
\ No newline at end of file
diff --git a/.idea/aws.xml b/.idea/aws.xml
new file mode 100644
index 0000000..b63b642
--- /dev/null
+++ b/.idea/aws.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/azureSettings.xml b/.idea/azureSettings.xml
new file mode 100644
index 0000000..448ab9e
--- /dev/null
+++ b/.idea/azureSettings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..1393a97
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..712ab9d
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_11_2.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_11_2.xml
new file mode 100644
index 0000000..6447563
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_11_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_11_2.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_11_2.xml
new file mode 100644
index 0000000..4923956
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_11_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_11_2.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_11_2.xml
new file mode 100644
index 0000000..bb59715
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_11_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_dataformat_jackson_dataformat_csv_2_11_2.xml b/.idea/libraries/Maven__com_fasterxml_jackson_dataformat_jackson_dataformat_csv_2_11_2.xml
new file mode 100644
index 0000000..c5892a6
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_dataformat_jackson_dataformat_csv_2_11_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_google_code_gson_gson_2_8_6.xml b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_6.xml
new file mode 100644
index 0000000..82a9f20
--- /dev/null
+++ b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_6.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml
new file mode 100644
index 0000000..d411041
--- /dev/null
+++ b/.idea/libraries/Maven__junit_junit_4_12.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
new file mode 100644
index 0000000..f58bbc1
--- /dev/null
+++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_openjfx_javafx_base_14.xml b/.idea/libraries/Maven__org_openjfx_javafx_base_14.xml
new file mode 100644
index 0000000..027403a
--- /dev/null
+++ b/.idea/libraries/Maven__org_openjfx_javafx_base_14.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_openjfx_javafx_base_mac_14.xml b/.idea/libraries/Maven__org_openjfx_javafx_base_mac_14.xml
new file mode 100644
index 0000000..68c771d
--- /dev/null
+++ b/.idea/libraries/Maven__org_openjfx_javafx_base_mac_14.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_openjfx_javafx_controls_14.xml b/.idea/libraries/Maven__org_openjfx_javafx_controls_14.xml
new file mode 100644
index 0000000..0d2cac3
--- /dev/null
+++ b/.idea/libraries/Maven__org_openjfx_javafx_controls_14.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_openjfx_javafx_controls_mac_14.xml b/.idea/libraries/Maven__org_openjfx_javafx_controls_mac_14.xml
new file mode 100644
index 0000000..3bc9d24
--- /dev/null
+++ b/.idea/libraries/Maven__org_openjfx_javafx_controls_mac_14.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_openjfx_javafx_graphics_14.xml b/.idea/libraries/Maven__org_openjfx_javafx_graphics_14.xml
new file mode 100644
index 0000000..a27f9bd
--- /dev/null
+++ b/.idea/libraries/Maven__org_openjfx_javafx_graphics_14.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_openjfx_javafx_graphics_mac_14.xml b/.idea/libraries/Maven__org_openjfx_javafx_graphics_mac_14.xml
new file mode 100644
index 0000000..c296845
--- /dev/null
+++ b/.idea/libraries/Maven__org_openjfx_javafx_graphics_mac_14.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..fd88c95
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..ea60d1f
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/coding-competition.iml b/coding-competition.iml
new file mode 100644
index 0000000..a4ebd89
--- /dev/null
+++ b/coding-competition.iml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/feedback.txt b/feedback.txt
index b931d50..449678a 100644
--- a/feedback.txt
+++ b/feedback.txt
@@ -1,9 +1,10 @@
-Your team (name of each individual participating):
-How many JUnits were you able to get to pass?
+Your team (name of each individual participating): Gagan Bhat
+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:
- Step 2:
+ Step 2: Ensured file opening and other potential run time exceptions are caught and printed out in detail.
+ Step 3: Followed Java encapsulation standards with getters and setters for every class and variable (future proofing).
Feedback for the coding competition? Things you would like to see in future events?
diff --git a/pom.xml b/pom.xml
index 21d55bf..69de4b2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,8 +12,25 @@
Coding Competition
+ 1.8
+ 1.8
+
+
+
+ org.openjfx
+ javafx-maven-plugin
+ 0.0.4
+
+ hellofx/org.openjfx.App
+
+
+
+
+
+
+
junit
@@ -27,6 +44,17 @@
jackson-dataformat-csv
2.11.2
+
+
+ com.google.code.gson
+ gson
+ 2.8.6
+
+
+ org.openjfx
+ javafx-controls
+ 14
+
diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java
index 58267da..441fcda 100644
--- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java
+++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java
@@ -1,20 +1,18 @@
package sf.codingcompetition2020;
import java.io.FileReader;
+import java.io.IOException;
import java.io.Reader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.lang.reflect.InvocationTargetException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.rmi.server.ExportException;
+import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
-
-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.CsvSchema;
+import java.util.stream.Stream;
import sf.codingcompetition2020.structures.Agent;
import sf.codingcompetition2020.structures.Claim;
@@ -30,7 +28,26 @@ public class CodingCompCsvUtil {
* @return -- List of entries being returned.
*/
public List readCsvFile(String filePath, Class classType) {
+ List list = new ArrayList<>();
+ try {
+ csvStreamer(filePath).skip(1).forEach(stringList -> {
+// if(classType == Agent.class)
+// list.add((T) new Agent(stringList));
+// if(classType == Claim.class)
+// list.add((T) new Claim(stringList));
+// if(classType == Customer.class)
+// list.add((T) new Customer(stringList));
+ try {
+ list.add(classType.getConstructor(List.class).newInstance(stringList));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return list;
}
@@ -41,7 +58,8 @@ public List readCsvFile(String filePath, Class classType) {
* @return -- The number of agents in a given area
*/
public int getAgentCountInArea(String filePath,String area) {
-
+ return (int) readCsvFile(filePath, Agent.class).stream()
+ .filter(ag -> ag.getArea().equals(area)).count();
}
@@ -53,7 +71,9 @@ 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 readCsvFile(filePath, Agent.class).stream()
+ .filter(a -> a.getLanguage().equals(language) && a.getArea().equals(area))
+ .collect(Collectors.toList());
}
@@ -66,7 +86,13 @@ 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) {
-
+
+ Object[] f = readCsvFile(csvFilePaths.get("agentList"), Agent.class).stream()
+ .filter(agent -> agent.getFirstName().equals(agentFirstName) && agent.getLastName().equals(agentLastName)).toArray();
+
+ return (short) (readCsvFile(csvFilePaths.get("customerList"), Customer.class).stream()
+ .filter(customer -> customer.getArea().equals(customerArea)
+ && customer.getAgentId() == ((Agent) f [0]).getAgentId()).count());
}
@@ -77,7 +103,17 @@ 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 custList = readCsvFile(customerFilePath, Customer.class);
+ List filterCustomer = new ArrayList<>();
+
+ custList.forEach(current -> {
+ if (current.getYearsOfService() == yearsOfService) {
+ filterCustomer.add(current);
+ }
+ });
+ Collections.sort(filterCustomer, Comparator.comparingInt(Customer::getTotalMonthlyPremiumString));
+ return filterCustomer;
}
@@ -88,7 +124,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 custList = readCsvFile(filePath, Customer.class);
+ List filterCustomer = new ArrayList<>();
+ for (Customer current : custList) {
+ if (!current.isAutoPolicy() && !current.isHomePolicy() && !current.isRentersPolicy())
+ filterCustomer.add(current);
+ }
+ return filterCustomer;
}
@@ -103,7 +146,13 @@ 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 vendors = new ArrayList<>();
+ readCsvFile(filePath, Vendor.class).stream().forEach(vendor -> {
+ if( (!inScope || vendor.isInScope()) && vendor.getArea().equals(area) && vendor.getVendorRating() >= vendorRating)
+ vendors.add(vendor);
+ });
+ return vendors;
}
@@ -117,8 +166,15 @@ 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 cust = readCsvFile(filePath, Customer.class);
- }
+ List customCust = new ArrayList<>();
+ for (Customer current : cust)
+ if (current.getAge() >= 40 && current.getAge() <= 50)
+ if (current.getVehiclesInsured() > vehiclesInsured && current.getDependents().size() <= dependents)
+ customCust.add(current);
+ return customCust;
+ }
/* #9
@@ -130,8 +186,42 @@ public List getUndisclosedDrivers(String filePath, int vehiclesInsured
* @return -- Agent ID of agent with the given rank.
*/
public int getAgentIdGivenRank(String filePath, int agentRank) {
-
- }
+
+
+ List custList = readCsvFile(filePath, Customer.class);
+
+ Map sumOfAgentRatings = new HashMap<>();
+ Map countOfAgentRatings = new HashMap<>();
+
+ custList.forEach(customer -> {
+ int id = customer.getAgentId();
+ double currentSumOfAgentRatings = 0;
+ int currentCountOfAgentRatings = 0;
+
+ if(sumOfAgentRatings.get(id) != null)
+ currentSumOfAgentRatings = sumOfAgentRatings.get(id);
+ if(countOfAgentRatings.get(id) != null)
+ currentCountOfAgentRatings = countOfAgentRatings.get(id);
+
+ double newSumOfAgentRatings = currentSumOfAgentRatings + (double) customer.getAgentRating();
+ int newCountOfAgentRatings = currentCountOfAgentRatings + 1;
+
+ sumOfAgentRatings.put(id, newSumOfAgentRatings);
+ countOfAgentRatings.put(id, newCountOfAgentRatings);
+ });
+
+ Map ratingCumulativeAverage = new HashMap<>();
+ for (Integer agentId: sumOfAgentRatings.keySet()) {
+ ratingCumulativeAverage.put(agentId, sumOfAgentRatings.get(agentId) / countOfAgentRatings.get(agentId));
+ }
+
+ List sortedAgents = ratingCumulativeAverage.entrySet().stream()
+ .sorted(Comparator.comparing(Map.Entry::getValue, Comparator.reverseOrder()))
+ .map(Map.Entry::getKey)
+ .collect(Collectors.toList());
+
+ return sortedAgents.get(agentRank-1);
+ }
/* #10
@@ -141,7 +231,33 @@ public int getAgentIdGivenRank(String filePath, int agentRank) {
* @return -- List of customers who’ve filed a claim within the last .
*/
public List getCustomersWithClaims(Map csvFilePaths, short monthsOpen) {
+ String customerListFilePath = csvFilePaths.get("customerList");
+ String claimsListFilePath = csvFilePaths.get("claimList");
+ List customerList = readCsvFile(customerListFilePath, Customer.class);
+ List claimsList = readCsvFile(claimsListFilePath, Claim.class);
- }
+ Set customersWithClaims = new HashSet<>();
+
+ claimsList.forEach(currClaim -> {
+ if (currClaim.getMonthsOpen() <= monthsOpen) {
+ int currentClaimCustomerId = currClaim.getCustomerId();
+ for(Customer cust : customerList)
+ if(cust.getCustomerId() == currentClaimCustomerId)
+ customersWithClaims.add(customerList.get(currentClaimCustomerId-1));
+
+ }
+ });
+ ArrayList list = new ArrayList<>();
+ list.addAll(customersWithClaims);
+ list.remove(0);
+ return list;
+ }
+
+ private Stream> csvStreamer(String fileName) throws IOException {
+ return Files.lines(Paths.get(fileName)).map(line -> {
+ String[] lineContents = line.split(",(?=([^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)");
+ return Arrays.asList(lineContents);
+ });
+ }
}
diff --git a/src/main/java/sf/codingcompetition2020/Pair.java b/src/main/java/sf/codingcompetition2020/Pair.java
new file mode 100644
index 0000000..219c16e
--- /dev/null
+++ b/src/main/java/sf/codingcompetition2020/Pair.java
@@ -0,0 +1,28 @@
+package sf.codingcompetition2020;
+
+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;
+ }
+}
diff --git a/src/main/java/sf/codingcompetition2020/structures/Agent.java b/src/main/java/sf/codingcompetition2020/structures/Agent.java
index e2e6f93..cf08200 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;
@@ -7,5 +9,49 @@ public class Agent {
private String language;
private String firstName;
private String lastName;
-
+
+ public 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;
+ }
+
+ public Agent(List list){
+ this(Integer.parseInt(list.get(0)), list.get(1), list.get(2), list.get(3), list.get(4));
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public int getAgentId() {
+ return agentId;
+ }
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
}
diff --git a/src/main/java/sf/codingcompetition2020/structures/Claim.java b/src/main/java/sf/codingcompetition2020/structures/Claim.java
index 581140a..d3bc2dd 100644
--- a/src/main/java/sf/codingcompetition2020/structures/Claim.java
+++ b/src/main/java/sf/codingcompetition2020/structures/Claim.java
@@ -1,9 +1,56 @@
package sf.codingcompetition2020.structures;
+import java.util.List;
+
public class Claim {
private int claimId;
private int customerId;
private boolean closed;
private int monthsOpen;
-
+
+ public Claim(int claimId, int customerId, boolean closed, int monthsOpen) {
+ this.claimId = claimId;
+ this.customerId = customerId;
+ this.closed = closed;
+ this.monthsOpen = monthsOpen;
+
+ }
+
+ public Claim(List stringList) {
+ this(Integer.parseInt(stringList.get(0)), Integer.parseInt(stringList.get(1)), Boolean.parseBoolean(stringList.get(2)),
+ Integer.parseInt(stringList.get(3)));
+ }
+
+
+ public int getClaimId() {
+ return claimId;
+ }
+
+ public void setClaimId(int claimId) {
+ this.claimId = claimId;
+ }
+
+ public int getCustomerId() {
+ return customerId;
+ }
+
+ public void setCustomerId(int customerId) {
+ this.customerId = customerId;
+ }
+
+ public boolean isClosed() {
+ return closed;
+ }
+
+ public void setClosed(boolean closed) {
+ this.closed = closed;
+ }
+
+ public int getMonthsOpen() {
+ return monthsOpen;
+ }
+
+ public void setMonthsOpen(int monthsOpen) {
+ this.monthsOpen = monthsOpen;
+ }
}
diff --git a/src/main/java/sf/codingcompetition2020/structures/Customer.java b/src/main/java/sf/codingcompetition2020/structures/Customer.java
index f151906..323b7f7 100644
--- a/src/main/java/sf/codingcompetition2020/structures/Customer.java
+++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java
@@ -1,12 +1,12 @@
package sf.codingcompetition2020.structures;
+import com.fasterxml.jackson.databind.node.BooleanNode;
+import com.google.gson.Gson;
+
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
public class Customer {
private int customerId;
private String firstName;
@@ -24,4 +24,183 @@ public class Customer {
private short yearsOfService;
private Integer vehiclesInsured;
-}
+ public Customer(int customerId, String firstName, String lastName, int age, String area, int agentId,
+ short agentRating, String primaryLanguage, String 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.homePolicy = homePolicy;
+ this.autoPolicy = autoPolicy;
+ this.rentersPolicy = rentersPolicy;
+ this.totalMonthlyPremium = totalMonthlyPremium;
+ this.yearsOfService = yearsOfService;
+ this.vehiclesInsured = vehiclesInsured;
+
+ if(dependents.length() == 0)
+ this.dependents = new ArrayList<>();
+ else {
+ dependents = dependents.substring(1, dependents.length() - 1 );
+ String jsonStr = (dependents.replace("\"\"", "\""));
+ Gson gson = new Gson();
+ this.dependents = Arrays.asList(gson.fromJson(jsonStr, Dependent[].class));
+ }
+ }
+
+ public Customer(List stringList) {
+ this(Integer.parseInt(stringList.get(0)), stringList.get(1), stringList.get(2), Integer.parseInt(stringList.get(3)), stringList.get(4), Integer.parseInt(stringList.get(5)),
+ Short.parseShort(stringList.get(6)), stringList.get(7), stringList.get(8), Boolean.parseBoolean(stringList.get(9)),
+ Boolean.parseBoolean(stringList.get(10)), Boolean.parseBoolean(stringList.get(11)), stringList.get(12), Short.parseShort(stringList.get(13)),
+ Integer.parseInt(stringList.get(14)));
+ }
+
+ public int getCustomerId() {
+ return customerId;
+ }
+
+ public void setCustomerId(int customerId) {
+ this.customerId = customerId;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public int getAgentId() {
+ return agentId;
+ }
+
+ public void setAgentId(int agentId) {
+ this.agentId = agentId;
+ }
+
+ public short getAgentRating() {
+ return agentRating;
+ }
+
+ public void setAgentRating(short agentRating) {
+ this.agentRating = agentRating;
+ }
+
+ public String getPrimaryLanguage() {
+ return primaryLanguage;
+ }
+
+ public void setPrimaryLanguage(String primaryLanguage) {
+ this.primaryLanguage = primaryLanguage;
+ }
+
+ public List getDependents() {
+ return dependents;
+ }
+
+ public void setDependents(List dependents) {
+ this.dependents = dependents;
+ }
+
+ public boolean isHomePolicy() {
+ return homePolicy;
+ }
+
+ public void setHomePolicy(boolean homePolicy) {
+ this.homePolicy = homePolicy;
+ }
+
+ public boolean isAutoPolicy() {
+ return autoPolicy;
+ }
+
+ public void setAutoPolicy(boolean autoPolicy) {
+ this.autoPolicy = autoPolicy;
+ }
+
+ public boolean isRentersPolicy() {
+ return rentersPolicy;
+ }
+
+ public void setRentersPolicy(boolean rentersPolicy) {
+ this.rentersPolicy = rentersPolicy;
+ }
+
+ public String getTotalMonthlyPremium() {
+ return totalMonthlyPremium;
+ }
+
+ public Integer getTotalMonthlyPremiumString() {
+ return Integer.parseInt(this.getTotalMonthlyPremium().substring(1));
+ }
+
+ public void setTotalMonthlyPremium(String totalMonthlyPremium) {
+ this.totalMonthlyPremium = totalMonthlyPremium;
+ }
+
+ public short getYearsOfService() {
+ return yearsOfService;
+ }
+
+ public void setYearsOfService(short yearsOfService) {
+ this.yearsOfService = yearsOfService;
+ }
+
+ public Integer getVehiclesInsured() {
+ return vehiclesInsured;
+ }
+
+ public void setVehiclesInsured(Integer 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 +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/sf/codingcompetition2020/structures/Dependent.java b/src/main/java/sf/codingcompetition2020/structures/Dependent.java
index d4deb1a..4974f11 100644
--- a/src/main/java/sf/codingcompetition2020/structures/Dependent.java
+++ b/src/main/java/sf/codingcompetition2020/structures/Dependent.java
@@ -4,4 +4,24 @@ public class Dependent {
private String firstName;
private String lastName;
+ public Dependent(String firstName, String lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
}
diff --git a/src/main/java/sf/codingcompetition2020/structures/Vendor.java b/src/main/java/sf/codingcompetition2020/structures/Vendor.java
index 6b6fb76..d9f81ca 100644
--- a/src/main/java/sf/codingcompetition2020/structures/Vendor.java
+++ b/src/main/java/sf/codingcompetition2020/structures/Vendor.java
@@ -1,9 +1,53 @@
package sf.codingcompetition2020.structures;
+import java.util.List;
+
public class Vendor {
private int vendorId;
private String area;
private int vendorRating;
private boolean inScope;
-
+
+ public Vendor(int vendorId, String area, int vendorRating, boolean inScope) {
+ this.vendorId = vendorId;
+ this.area = area;
+ this.vendorRating = vendorRating;
+ this.inScope = inScope;
+ }
+
+ public Vendor(List s){
+ this(Integer.parseInt(s.get(0)), s.get(1), Integer.parseInt(s.get(2)), Boolean.parseBoolean(s.get(3)));
+ }
+
+ public int getVendorId() {
+ return vendorId;
+ }
+
+ public void setVendorId(int vendorId) {
+ this.vendorId = vendorId;
+ }
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public int getVendorRating() {
+ return vendorRating;
+ }
+
+ public void setVendorRating(int vendorRating) {
+ this.vendorRating = vendorRating;
+ }
+
+ public boolean isInScope() {
+ return inScope;
+ }
+
+ public void setInScope(boolean inScope) {
+ this.inScope = inScope;
+ }
}
diff --git a/src/main/resources/DataFiles/claims.csv b/src/main/resources/DataFiles/claims.csv
index 627b227..a32cc86 100644
--- a/src/main/resources/DataFiles/claims.csv
+++ b/src/main/resources/DataFiles/claims.csv
@@ -1,6 +1,6 @@
claimId,customerId,closed,monthsOpen
1,140,false,8
-2,310,true,11
+2,310,true,1
3,353,true,4
4,498,false,9
5,106,false,6
diff --git a/src/main/resources/DataFiles/customers.csv b/src/main/resources/DataFiles/customers.csv
index 3815d12..e041b8a 100644
--- a/src/main/resources/DataFiles/customers.csv
+++ b/src/main/resources/DataFiles/customers.csv
@@ -498,4 +498,4 @@ customerId,firstName,lastName,age,area,agentId,agentRating,primaryLanguage,depen
497,Gavan,Fargher,94,area-3,20,4,Arabic,,true,false,false,$323,47,0
498,Ofella,Winkless,63,area-5,17,2,Arabic,,false,true,true,$613,25,2
499,Cammy,Leffek,23,area-5,2,1,English,"[{""firstName"":""Phyllis"",""lastName"":""Stokell""},{""firstName"":""Lurleen"",""lastName"":""Gittis""},{""firstName"":""Bern"",""lastName"":""Lisett""}]",true,true,false,$674,5,3
-500,Lorin,Charles,31,area-4,15,3,Arabic,"[{""firstName"":""Piggy"",""lastName"":""Hymor""},{""firstName"":""Ursala"",""lastName"":""Crumbie""},{""firstName"":""Ingamar"",""lastName"":""Churching""},{""firstName"":""Easter"",""lastName"":""Blaskett""},{""firstName"":""Cathie"",""lastName"":""Simmig""}]",true,false,false,$658,2,0
+500,Lorin,Charles,31,area-4,15,3,Arabic,"[{""firstName"":""Piggy"",""lastName"":""Hymor""},{""firstName"":""Ursala"",""lastName"":""Crumbie""},{""firstName"":""Ingamar"",""lastName"":""Churching""},{""firstName"":""Easter"",""lastName"":""Blaskett""},{""firstName"":""Cathie"",""lastName"":""Simmig""}]",true,false,false,$658,2,0
\ No newline at end of file
diff --git a/target/classes/DataFiles/claims.csv b/target/classes/DataFiles/claims.csv
index 627b227..a32cc86 100644
--- a/target/classes/DataFiles/claims.csv
+++ b/target/classes/DataFiles/claims.csv
@@ -1,6 +1,6 @@
claimId,customerId,closed,monthsOpen
1,140,false,8
-2,310,true,11
+2,310,true,1
3,353,true,4
4,498,false,9
5,106,false,6
diff --git a/target/classes/DataFiles/customers.csv b/target/classes/DataFiles/customers.csv
index 3815d12..e041b8a 100644
--- a/target/classes/DataFiles/customers.csv
+++ b/target/classes/DataFiles/customers.csv
@@ -498,4 +498,4 @@ customerId,firstName,lastName,age,area,agentId,agentRating,primaryLanguage,depen
497,Gavan,Fargher,94,area-3,20,4,Arabic,,true,false,false,$323,47,0
498,Ofella,Winkless,63,area-5,17,2,Arabic,,false,true,true,$613,25,2
499,Cammy,Leffek,23,area-5,2,1,English,"[{""firstName"":""Phyllis"",""lastName"":""Stokell""},{""firstName"":""Lurleen"",""lastName"":""Gittis""},{""firstName"":""Bern"",""lastName"":""Lisett""}]",true,true,false,$674,5,3
-500,Lorin,Charles,31,area-4,15,3,Arabic,"[{""firstName"":""Piggy"",""lastName"":""Hymor""},{""firstName"":""Ursala"",""lastName"":""Crumbie""},{""firstName"":""Ingamar"",""lastName"":""Churching""},{""firstName"":""Easter"",""lastName"":""Blaskett""},{""firstName"":""Cathie"",""lastName"":""Simmig""}]",true,false,false,$658,2,0
+500,Lorin,Charles,31,area-4,15,3,Arabic,"[{""firstName"":""Piggy"",""lastName"":""Hymor""},{""firstName"":""Ursala"",""lastName"":""Crumbie""},{""firstName"":""Ingamar"",""lastName"":""Churching""},{""firstName"":""Easter"",""lastName"":""Blaskett""},{""firstName"":""Cathie"",""lastName"":""Simmig""}]",true,false,false,$658,2,0
\ No newline at end of file
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
index 00daba9..cd2f936 100644
Binary files a/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class and b/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class differ
diff --git a/target/classes/sf/codingcompetition2020/Pair.class b/target/classes/sf/codingcompetition2020/Pair.class
new file mode 100644
index 0000000..afff00d
Binary files /dev/null and b/target/classes/sf/codingcompetition2020/Pair.class differ
diff --git a/target/classes/sf/codingcompetition2020/TableViewExample.class b/target/classes/sf/codingcompetition2020/TableViewExample.class
new file mode 100644
index 0000000..64e80c6
Binary files /dev/null and b/target/classes/sf/codingcompetition2020/TableViewExample.class differ
diff --git a/target/classes/sf/codingcompetition2020/structures/Agent.class b/target/classes/sf/codingcompetition2020/structures/Agent.class
index 26bf31f..7c71f25 100644
Binary files a/target/classes/sf/codingcompetition2020/structures/Agent.class and b/target/classes/sf/codingcompetition2020/structures/Agent.class differ
diff --git a/target/classes/sf/codingcompetition2020/structures/Claim.class b/target/classes/sf/codingcompetition2020/structures/Claim.class
index 1ce796d..2606a90 100644
Binary files a/target/classes/sf/codingcompetition2020/structures/Claim.class and b/target/classes/sf/codingcompetition2020/structures/Claim.class differ
diff --git a/target/classes/sf/codingcompetition2020/structures/Customer.class b/target/classes/sf/codingcompetition2020/structures/Customer.class
index 844ea29..05ae2ba 100644
Binary files a/target/classes/sf/codingcompetition2020/structures/Customer.class and b/target/classes/sf/codingcompetition2020/structures/Customer.class differ
diff --git a/target/classes/sf/codingcompetition2020/structures/Dependent.class b/target/classes/sf/codingcompetition2020/structures/Dependent.class
index 3ee505f..2307896 100644
Binary files a/target/classes/sf/codingcompetition2020/structures/Dependent.class and b/target/classes/sf/codingcompetition2020/structures/Dependent.class differ
diff --git a/target/classes/sf/codingcompetition2020/structures/Vendor.class b/target/classes/sf/codingcompetition2020/structures/Vendor.class
index fdbca9b..ef263f1 100644
Binary files a/target/classes/sf/codingcompetition2020/structures/Vendor.class and b/target/classes/sf/codingcompetition2020/structures/Vendor.class differ
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 0000000..e69de29
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 0000000..495684b
--- /dev/null
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1,8 @@
+/Users/gaganbhat/Documents/Programming/State-Farm/2020-StateFarm-CodingCompetitionProblem/src/main/java/sf/codingcompetition2020/structures/Agent.java
+/Users/gaganbhat/Documents/Programming/State-Farm/2020-StateFarm-CodingCompetitionProblem/src/main/java/sf/codingcompetition2020/TableViewExample.java
+/Users/gaganbhat/Documents/Programming/State-Farm/2020-StateFarm-CodingCompetitionProblem/src/main/java/sf/codingcompetition2020/structures/Customer.java
+/Users/gaganbhat/Documents/Programming/State-Farm/2020-StateFarm-CodingCompetitionProblem/src/main/java/sf/codingcompetition2020/structures/Dependent.java
+/Users/gaganbhat/Documents/Programming/State-Farm/2020-StateFarm-CodingCompetitionProblem/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java
+/Users/gaganbhat/Documents/Programming/State-Farm/2020-StateFarm-CodingCompetitionProblem/src/main/java/sf/codingcompetition2020/structures/Claim.java
+/Users/gaganbhat/Documents/Programming/State-Farm/2020-StateFarm-CodingCompetitionProblem/src/main/java/sf/codingcompetition2020/Pair.java
+/Users/gaganbhat/Documents/Programming/State-Farm/2020-StateFarm-CodingCompetitionProblem/src/main/java/sf/codingcompetition2020/structures/Vendor.java
diff --git a/target/test-classes/sf/codingcompetition2020/CodingCompCsvUtilTest.class b/target/test-classes/sf/codingcompetition2020/CodingCompCsvUtilTest.class
index 765ac60..792b53b 100644
Binary files a/target/test-classes/sf/codingcompetition2020/CodingCompCsvUtilTest.class and b/target/test-classes/sf/codingcompetition2020/CodingCompCsvUtilTest.class differ