diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..5e8d853
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b83d222
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/.project b/.project
new file mode 100644
index 0000000..5edc1ee
--- /dev/null
+++ b/.project
@@ -0,0 +1,23 @@
+
+
+ coding-competition
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..b9a1035
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,15 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/feedback.txt b/feedback.txt
index b931d50..17e7197 100644
--- a/feedback.txt
+++ b/feedback.txt
@@ -1,5 +1,5 @@
-Your team (name of each individual participating):
-How many JUnits were you able to get to pass?
+Your team (name of each individual participating): Rachel Masters, Caspian Siebert
+How many JUnits were you able to get to pass? 4
Document and describe any enhancements included to help the judges properly grade your submission.
Step 1:
@@ -7,3 +7,4 @@ Document and describe any enhancements included to help the judges properly grad
Feedback for the coding competition? Things you would like to see in future events?
+It was really cool!
\ 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 58267da..d731415 100644
--- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java
+++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java
@@ -1,6 +1,9 @@
package sf.codingcompetition2020;
+import java.io.BufferedReader;
+import java.io.File;
import java.io.FileReader;
+import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.HashMap;
@@ -29,8 +32,106 @@ public class CodingCompCsvUtil {
* @param classType -- Class of entries being read in.
* @return -- List of entries being returned.
*/
+ @SuppressWarnings("unchecked")
public List readCsvFile(String filePath, Class classType) {
-
+ //this is a test
+ try {
+ File file = new File(filePath);
+ FileReader fr = new FileReader(file);
+ BufferedReader br = new BufferedReader(fr);
+
+ if(classType==Agent.class) {
+ List agents = new ArrayList();
+ String vars = br.readLine();
+ String line="";
+ String[] arr = new String[5];
+
+ while((line = br.readLine())!=null) {
+ arr=line.split(",");
+ Agent p = new Agent();
+ p.setAgentId(Integer.parseInt(arr[0]));
+ p.setArea(arr[1]);
+ p.setLanguage(arr[2]);
+ p.setFirstName(arr[3]);
+ p.setLastName(arr[4]);
+ agents.add(p);
+ }
+ return (List)agents;
+ }
+ else if(classType==Claim.class) {
+ List claims = new ArrayList();
+ String vars = br.readLine();
+ String line="";
+ String[] arr = new String[4];
+
+ while((line = br.readLine())!=null) {
+ arr=line.split(",");
+ Claim c = new Claim();
+ c.setClaimId(Integer.parseInt(arr[0]));
+ c.setCustomerId(Integer.parseInt(arr[1]));
+ c.setClosed(Boolean.parseBoolean(arr[2]));
+ c.setMonthsOpen(Integer.parseInt(arr[3]));
+ claims.add(c);
+ }
+ return (List)claims;
+ }
+ else if(classType==Customer.class) {
+ List customers = new ArrayList();
+ String vars = br.readLine();
+ String line="";
+ String[] arr = new String[15];
+
+ while((line = br.readLine())!=null) {
+ arr=line.split(",");
+ Customer c = new Customer();
+ c.setCustomerId(Integer.parseInt(arr[0]));
+ c.setFirstName(arr[1]);
+ c.setLastName(arr[2]);
+ c.setAge(Integer.parseInt(arr[3]));
+ c.setArea(arr[4]);
+ c.setAgentId(Integer.parseInt(arr[5]));
+ c.setAgentRating((short) Integer.parseInt(arr[6]));
+ c.setPrimaryLanguage(arr[7]);
+
+ //String dependent = arr[8];
+
+ //c.setDependents();
+
+
+ //c.setHomePolicy(Boolean.parseBoolean(arr[9]));
+ //c.setAutoPolicy(Boolean.parseBoolean(arr[10]));
+ //c.setRentersPolicy(Boolean.parseBoolean(arr[11]));
+ //c.setTotalMonthlyPremium(arr[12]);
+ //c.setYearsOfService((short) Integer.parseInt(arr[13]));
+ //c.setVehiclesInsured(Integer.parseInt(arr[14]));
+ customers.add(c);
+ }
+ return (List)customers;
+ }
+ else {
+ List vendors = new ArrayList();
+ String vars = br.readLine();
+ String line="";
+ String[] arr = new String[4];
+
+ while((line = br.readLine())!=null) {
+ arr=line.split(",");
+ Vendor v = new Vendor();
+ v.setVendorId(Integer.parseInt(arr[0]));
+ v.setArea(arr[1]);
+ v.setVendorRating(Integer.parseInt(arr[2]));
+ v.setInScope(Boolean.parseBoolean(arr[3]));
+ vendors.add(v);
+ }
+ return (List)vendors;
+ }
+
+ }
+ catch(IOException e) {
+ System.out.println(e);
+
+ }
+ return null;
}
@@ -41,7 +142,12 @@ public List readCsvFile(String filePath, Class classType) {
* @return -- The number of agents in a given area
*/
public int getAgentCountInArea(String filePath,String area) {
-
+ List agents = readCsvFile(filePath,Agent.class);
+ int numInArea = 0;
+ for(Agent a : agents) {
+ if(a.getArea().equals(area)) numInArea++;
+ }
+ return numInArea;
}
@@ -53,7 +159,12 @@ 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) {
-
+ List agents = readCsvFile(filePath,Agent.class);
+ List agentsInParam = new ArrayList();
+ for(Agent a : agents) {
+ if(a.getArea().equals(area) & a.getLanguage().equals(language)) agentsInParam.add(a);
+ }
+ return agentsInParam;
}
@@ -66,7 +177,19 @@ 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) {
-
+ List agents = readCsvFile(csvFilePaths.get("agentList"),Agent.class);
+ List customers = readCsvFile(csvFilePaths.get("customerList"),Customer.class);
+ int agentId = -1;
+ short numCustomers = 0;
+ for(Agent a : agents) {
+ if(a.getFirstName().equals(agentFirstName) & a.getLastName().equals(agentLastName)) {
+ agentId = a.getAgentId();
+ }
+ }
+ for(Customer c : customers) {
+ if(c.getArea().equals(customerArea) & c.getAgentId()==agentId) numCustomers++;
+ }
+ return numCustomers;
}
@@ -77,7 +200,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;
}
@@ -88,7 +211,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;
}
@@ -103,7 +226,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;
}
@@ -117,7 +240,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) {
-
+ return null;
}
@@ -130,7 +253,7 @@ public List getUndisclosedDrivers(String filePath, int vehiclesInsured
* @return -- Agent ID of agent with the given rank.
*/
public int getAgentIdGivenRank(String filePath, int agentRank) {
-
+ return 0;
}
@@ -141,7 +264,7 @@ 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) {
-
+ return null;
}
}
diff --git a/src/main/java/sf/codingcompetition2020/structures/Agent.java b/src/main/java/sf/codingcompetition2020/structures/Agent.java
index e2e6f93..f75bf2b 100644
--- a/src/main/java/sf/codingcompetition2020/structures/Agent.java
+++ b/src/main/java/sf/codingcompetition2020/structures/Agent.java
@@ -8,4 +8,36 @@ public class Agent {
private String firstName;
private String lastName;
+ public int getAgentId() {
+ return agentId;
+ }
+ public void setAgentId(int agentId) {
+ this.agentId = 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 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/Claim.java b/src/main/java/sf/codingcompetition2020/structures/Claim.java
index 581140a..45757d2 100644
--- a/src/main/java/sf/codingcompetition2020/structures/Claim.java
+++ b/src/main/java/sf/codingcompetition2020/structures/Claim.java
@@ -6,4 +6,31 @@ public class Claim {
private boolean closed;
private int monthsOpen;
+ 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..e9640b5 100644
--- a/src/main/java/sf/codingcompetition2020/structures/Customer.java
+++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java
@@ -23,5 +23,96 @@ public class Customer {
private String totalMonthlyPremium;
private short yearsOfService;
private Integer vehiclesInsured;
+
+ 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 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;
+ }
}
diff --git a/src/main/java/sf/codingcompetition2020/structures/Dependent.java b/src/main/java/sf/codingcompetition2020/structures/Dependent.java
index d4deb1a..4e8c5fb 100644
--- a/src/main/java/sf/codingcompetition2020/structures/Dependent.java
+++ b/src/main/java/sf/codingcompetition2020/structures/Dependent.java
@@ -3,5 +3,20 @@
public class Dependent {
private String firstName;
private String 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..28e1742 100644
--- a/src/main/java/sf/codingcompetition2020/structures/Vendor.java
+++ b/src/main/java/sf/codingcompetition2020/structures/Vendor.java
@@ -6,4 +6,30 @@ public class Vendor {
private int vendorRating;
private boolean inScope;
+ 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/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..ae872be 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/structures/Agent.class b/target/classes/sf/codingcompetition2020/structures/Agent.class
index 26bf31f..a840a84 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..aad8492 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..6801c34 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..c157c6f 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..7fa26ad 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/test-classes/sf/codingcompetition2020/CodingCompCsvUtilTest.class b/target/test-classes/sf/codingcompetition2020/CodingCompCsvUtilTest.class
index 765ac60..66d8453 100644
Binary files a/target/test-classes/sf/codingcompetition2020/CodingCompCsvUtilTest.class and b/target/test-classes/sf/codingcompetition2020/CodingCompCsvUtilTest.class differ