From ad50307719afe87b5a4ff717705de6ec308d169d Mon Sep 17 00:00:00 2001 From: nishantbalepur Date: Sat, 10 Oct 2020 20:37:50 -0500 Subject: [PATCH 1/5] First commit --- .classpath | 49 ++++++++ .project | 23 ++++ .settings/org.eclipse.jdt.apt.core.prefs | 2 + .settings/org.eclipse.jdt.core.prefs | 9 ++ .settings/org.eclipse.m2e.core.prefs | 4 + .../CodingCompCsvUtil.java | 20 +-- .../structures/Agent.java | 47 +++++++ .../structures/Claim.java | 37 ++++++ .../structures/Customer.java | 116 ++++++++++++++++++ .../structures/Dependent.java | 25 ++++ .../structures/Vendor.java | 36 ++++++ .../CodingCompCsvUtilTest.java | 4 +- target/classes/META-INF/MANIFEST.MF | 4 +- .../coding-competition/pom.properties | 8 +- .../CodingCompCsvUtil.class | Bin 3251 -> 3274 bytes .../structures/Agent.class | Bin 428 -> 1600 bytes .../structures/Claim.class | Bin 397 -> 1276 bytes .../structures/Customer.class | Bin 806 -> 4597 bytes .../structures/Dependent.class | Bin 384 -> 928 bytes .../structures/Vendor.class | Bin 419 -> 1358 bytes .../CodingCompCsvUtilTest.class | Bin 3972 -> 5230 bytes 21 files changed, 366 insertions(+), 18 deletions(-) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.jdt.apt.core.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..1b799f3 --- /dev/null +++ b/.classpath @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..14a0591 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + 2020-StateFarm-CodingCompetitionProblem + + + + + + 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.apt.core.prefs b/.settings/org.eclipse.jdt.apt.core.prefs new file mode 100644 index 0000000..d4313d4 --- /dev/null +++ b/.settings/org.eclipse.jdt.apt.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.apt.aptEnabled=false diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ac8e750 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.processAnnotations=disabled +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.5 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/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 58267da..75152d7 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -30,7 +30,7 @@ public class CodingCompCsvUtil { * @return -- List of entries being returned. */ public List readCsvFile(String filePath, Class classType) { - + return null; } @@ -41,7 +41,7 @@ public List readCsvFile(String filePath, Class classType) { * @return -- The number of agents in a given area */ public int getAgentCountInArea(String filePath,String area) { - + return 0; } @@ -53,7 +53,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; } @@ -66,7 +66,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 0; } @@ -77,7 +77,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 +88,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 +103,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 +117,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 +130,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 +141,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..b5379e4 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Agent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Agent.java @@ -8,4 +8,51 @@ public class Agent { private String firstName; private String lastName; + public Agent() { + + } + + public Agent(int agentId, String area, String language, String firstName, String lastName) { + super(); + this.agentId = agentId; + this.area = area; + this.language = language; + this.firstName = firstName; + this.lastName = 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..f9d8ce1 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Claim.java +++ b/src/main/java/sf/codingcompetition2020/structures/Claim.java @@ -6,4 +6,41 @@ public class Claim { private boolean closed; private int monthsOpen; + public Claim() {} + + public Claim(int claimId, int customerId, boolean closed, int monthsOpen) { + super(); + this.claimId = claimId; + this.customerId = customerId; + this.closed = closed; + this.monthsOpen = 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..3bb1d0a 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Customer.java +++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java @@ -23,5 +23,121 @@ public class Customer { private String totalMonthlyPremium; private short yearsOfService; private Integer vehiclesInsured; + + public Customer() {} + + 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) { + super(); + 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; + } + 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..f247909 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Dependent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Dependent.java @@ -3,5 +3,30 @@ public class Dependent { private String firstName; private String lastName; + + + public Dependent() {} + + + public Dependent(String firstName, String lastName) { + super(); + 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..bb8c532 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Vendor.java +++ b/src/main/java/sf/codingcompetition2020/structures/Vendor.java @@ -6,4 +6,40 @@ public class Vendor { private int vendorRating; private boolean inScope; + public Vendor() {} + + public Vendor(int vendorId, String area, int vendorRating, boolean inScope) { + super(); + this.vendorId = vendorId; + this.area = area; + this.vendorRating = vendorRating; + this.inScope = 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/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java index c29959f..85bb197 100644 --- a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java +++ b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java @@ -56,7 +56,7 @@ public void getAgentsInAreaThatSpeakLanguage() { //#4 @Test public void countCustomersFromCitythatUseAgent() { - Map csvFilePaths = new HashMap<>(); + Map csvFilePaths = new HashMap(); csvFilePaths.put(agentList, agentFilePath); csvFilePaths.put(customerList, customerFilePath); @@ -111,7 +111,7 @@ public void getAgentIdGivenRank() { //#10 @Test public void getCountCustomersWithClaims() { - Map csvFilePaths = new HashMap<>(); + Map csvFilePaths = new HashMap(); csvFilePaths.put(customerList, customerFilePath); csvFilePaths.put(claimList, claimFilePath); diff --git a/target/classes/META-INF/MANIFEST.MF b/target/classes/META-INF/MANIFEST.MF index e2a1a34..783fe69 100644 --- a/target/classes/META-INF/MANIFEST.MF +++ b/target/classes/META-INF/MANIFEST.MF @@ -1,5 +1,5 @@ Manifest-Version: 1.0 -Built-By: yc1d -Build-Jdk: 1.8.0_201 +Built-By: nishu +Build-Jdk: 14.0.2 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 index fe569e3..c0c04b4 100644 --- a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties +++ b/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties @@ -1,7 +1,7 @@ #Generated by Maven Integration for Eclipse -#Thu Oct 08 09:27:33 MST 2020 -version=1.0.0-SNAPSHOT -groupId=sf.codingcompetition2020 +#Sat Oct 10 20:35:07 CDT 2020 +m2e.projectLocation=C\:\\Users\\nishu\\OneDrive\\Desktop\\Code\\2020-StateFarm-CodingCompetitionProblem m2e.projectName=coding-competition -m2e.projectLocation=/Users/yc1d/Development/coding-competition/problem/online-competition +groupId=sf.codingcompetition2020 artifactId=coding-competition +version=1.0.0-SNAPSHOT diff --git a/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class b/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class index 00daba9d49249e6950fa6b4b75732ac294bb504b..c2efa15eff5663b1b537df7f10493a4dece2f42b 100644 GIT binary patch literal 3274 zcmb_eT~pge6uoOq2!sIna=%-kNx+oGl!i2oU0ULV#2q&<*wAVEw8(2)#FjkTH4}b7 z-}^)Q&^~ph5B&lCQJtRMwQM<-sfPANT3zj)J?GxDSNiMkKmH`5&uDjwQjFGQJ?Ho} z*K0U_yCamVT;JQ=*xbk!O|*z;QJx+uw>3p+MhhqWl;>L9YvlHhPlTfwT`IVqtF{?U ztY(iGrLj=V&;(7-(j;ACG+%Z-@uJ&47D1ICw*;f>W#8egBObW=xfe{UrYjk(my`Dcc>5AL%xatPLI4o2jMb=oA z`RxSAg=#gwJpyl|j4szfai6QE)<41$930KAde#AlYmo_-G^5OL(lD==xXhcA!yRul zgxYBcPZj;Hr%K)qa>Z!nd?mfCWlN|eHwzX+7-=D@O|B{(!C#f(f-Y}>@AE{M5uV{L zHWV#I_kV&ajQ5dLLD$j6mN}Ci6bZCp$emk8jWoKhYe>PdtkI1apdMBRnSTp%{o2t)-rP_vZr?4 zK<Kje1`-fie%Dw}ufC3Sg9lwfcEJ5Q?Ky)OP*g2f+jR_-w!BoE3ekcBI4TPK+@s zF=zQO$-HFl2&ox^EQC4Ht;U|?xiigkuU-+ssp}vw4Ar~|O=UDC2^}R*b_4F|SGQwm z#jvj?n05j3D5 z^jP|)6jN@lWl5dNo%%EnkY-lK^@HIQ?!6!&01-qeK&v5g&5V z{HbWVPD`Md!WyE+Xr?AQ5P$;)g8i0Vs`YB*y+Z4cW1~Ctv^j?d+)Rp|C0%5EINUZc zmwT(j_L7e~HLu^8l<)|TKwTguGi~2PAKF6}kd2Dp4IE)V=b4dzkbC;WNlS#E4gACq zUBL)H8Msd2DTh15eRA!0y8IgkDVo7mzb1MclZj^S1l+IUiP0R*W7Y!3DY|Ar4iMGg zDfTO_6A^?ZgRp4d_7L>C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{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 index 26bf31f236fb6fb54997543cc9d682faad0ab137..4408829538b8aea3ed6ceb598907799181ff368a 100644 GIT binary patch literal 1600 zcmbV~-%b-z5XQe#`j2H5C{QUBs35xC0t={D8WLkd(xkx)4EIY}>XOo$?bavpF}%>k z#>5LBz=tw^bGFcCyG@KYJ9Ey?eDj-`^ZU=wUjUA9m_tgT+Pij|-7CM-YIbiwdZ8cs z-Olmh@uAZTgMKsY2VT#4)ABlD4rzsj8~2mzwB1h2d3Sl^HA97*D}U=(3aYMoZ(o_Sz46;hB3&pVxP8_O;*f!xM!Wt9n7Px7{nxzzh~ln0TNt z-|#!$S^xIZ3*NhzZ6+5Q-KN{Va06e?!^?E|!S5;58vooJ=^9pj68iscsu#0Rcw{1j ztav38IpoD#H!&M|8zzj%+cGhSyn@m4LOp4jB?rK18ojZrv{jd(l>gOp5!UP|VnEvKO^XQ3@8L2ELD3+MMCPtR!;ZN~nA`ENRGkza!{;ONo}EYOoA zDYArRS`k>`R|GyYQp#3Dz+NAqXzvZMYVQxQW|z_fl~}n*xojFhRG+4mSS1m+NgK-^d1Xg&0-J#Yv$m-V^$W|iAQ#_jh zsd2n_sb`wFW$slWS5Q`wyDIl^g0kIQ7%5jidB1kP6q#Or1 rAc!*sL|%)4>?MM1#zBq}LH3hD#vXd~MqUu)SN delta 80 zcmX@Wvxb@L)W2Q(7#J7~8N@eo@iR`2V)E8uWME|AVc-Rld_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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 1a7b50caf5599425245a512dfeaab1a235b6e016 Mon Sep 17 00:00:00 2001 From: nishantbalepur Date: Sat, 10 Oct 2020 21:43:58 -0500 Subject: [PATCH 2/5] Finished test1 --- pom.xml | 6 ++ .../CodingCompCsvUtil.java | 49 ++++++++++++++- .../structures/Agent.java | 9 ++- .../structures/Claim.java | 8 ++- .../structures/Customer.java | 57 ++++++++++++++++-- .../coding-competition/pom.properties | 2 +- .../coding-competition/pom.xml | 6 ++ .../CodingCompCsvUtil.class | Bin 3274 -> 4931 bytes .../structures/Agent.class | Bin 1600 -> 1887 bytes .../structures/Claim.class | Bin 1276 -> 1665 bytes .../structures/Customer.class | Bin 4597 -> 6407 bytes 11 files changed, 128 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 21d55bf..b24cf68 100644 --- a/pom.xml +++ b/pom.xml @@ -27,6 +27,12 @@ jackson-dataformat-csv 2.11.2 + + + org.json + json + 20180130 + diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 75152d7..4528041 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -1,12 +1,17 @@ package sf.codingcompetition2020; +import java.io.File; +import java.io.FileNotFoundException; import java.io.FileReader; import java.io.Reader; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Scanner; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -30,7 +35,49 @@ public class CodingCompCsvUtil { * @return -- List of entries being returned. */ public List readCsvFile(String filePath, Class classType) { - return null; + + + + Scanner scanner = null; + try { + scanner = new Scanner(new File(filePath)); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + List entries = new ArrayList(); + + scanner.nextLine(); + while (scanner.hasNextLine()) { + String entry = scanner.nextLine(); + // System.out.println(entry); + + try { + T obj = classType.getDeclaredConstructor(String.class).newInstance(entry); + entries.add(obj); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return entries; } diff --git a/src/main/java/sf/codingcompetition2020/structures/Agent.java b/src/main/java/sf/codingcompetition2020/structures/Agent.java index b5379e4..416f1a2 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Agent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Agent.java @@ -8,8 +8,13 @@ public class Agent { private String firstName; private String lastName; - public Agent() { - + public Agent(String args) { + String[] arguments = args.split(","); + agentId = Integer.parseInt(arguments[0]); + area = arguments[1]; + language = arguments[2]; + firstName = arguments[3]; + lastName = arguments[4]; } public Agent(int agentId, String area, String language, String firstName, String lastName) { diff --git a/src/main/java/sf/codingcompetition2020/structures/Claim.java b/src/main/java/sf/codingcompetition2020/structures/Claim.java index f9d8ce1..1e0458b 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Claim.java +++ b/src/main/java/sf/codingcompetition2020/structures/Claim.java @@ -6,7 +6,13 @@ public class Claim { private boolean closed; private int monthsOpen; - public Claim() {} + public Claim(String args) { + String[] arguments = args.split(","); + claimId = Integer.parseInt(arguments[0]); + customerId = Integer.parseInt(arguments[1]); + closed = arguments[2].equals("true"); + monthsOpen = Integer.parseInt(arguments[3]); + } public Claim(int claimId, int customerId, boolean closed, int monthsOpen) { super(); diff --git a/src/main/java/sf/codingcompetition2020/structures/Customer.java b/src/main/java/sf/codingcompetition2020/structures/Customer.java index 3bb1d0a..dc9b124 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Customer.java +++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java @@ -1,11 +1,13 @@ package sf.codingcompetition2020.structures; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.regex.Pattern; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; public class Customer { private int customerId; @@ -24,7 +26,54 @@ public class Customer { private short yearsOfService; private Integer vehiclesInsured; - public Customer() {} + public Customer(String args) { + //System.out.println(args); + args = args.replaceAll(",,", ",~,"); + args = args.replaceAll("\",\"", " ~ "); + args = args.replaceAll("},", "}~"); + + String[] arguments = args.split(","); + + //System.out.println(Arrays.asList(arguments)); + + customerId = Integer.parseInt(arguments[0]); + firstName = arguments[1]; + lastName = arguments[2]; + age = Integer.parseInt(arguments[3]); + area = arguments[4]; + agentId = Integer.parseInt(arguments[5]); + agentRating = Short.parseShort(arguments[6]); + primaryLanguage = arguments[7]; + + homePolicy = arguments[9].equals("true"); + autoPolicy = arguments[10].equals("true"); + rentersPolicy = arguments[11].equals("true"); + totalMonthlyPremium = arguments[12]; + yearsOfService = Short.parseShort(arguments[13]); + vehiclesInsured = Integer.parseInt(arguments[14]); + + dependents = new ArrayList(); + if (!arguments[8].equals("~")) { + String json = arguments[8]; + json = json.replaceAll(" ~ ", "\",\""); + json = json.replaceAll("}~", "},"); + json = json.replaceAll("\"\"", "\""); + json = json.substring(1, json.length() - 1); + + try { + JSONArray jsonArray = new JSONArray(json); + + for (int i = 0 ; i < jsonArray.length(); i++) { + JSONObject obj = jsonArray.getJSONObject(i); + Dependent dependent = new Dependent(obj.getString("firstName"), obj.getString("lastName")); + dependents.add(dependent); + } + + } catch (JSONException err){ + System.out.println("error"); + } + } + } public Customer(int customerId, String firstName, String lastName, int age, String area, int agentId, short agentRating, String primaryLanguage, List dependents, boolean homePolicy, 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 index c0c04b4..745636c 100644 --- a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties +++ b/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Sat Oct 10 20:35:07 CDT 2020 +#Sat Oct 10 21:33:31 CDT 2020 m2e.projectLocation=C\:\\Users\\nishu\\OneDrive\\Desktop\\Code\\2020-StateFarm-CodingCompetitionProblem m2e.projectName=coding-competition groupId=sf.codingcompetition2020 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 index 21d55bf..b24cf68 100644 --- a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.xml +++ b/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.xml @@ -27,6 +27,12 @@ jackson-dataformat-csv 2.11.2 + + + org.json + json + 20180130 + diff --git a/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class b/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class index c2efa15eff5663b1b537df7f10493a4dece2f42b..5cf5b43c542c955cc2c6340476b323647d8f4c1a 100644 GIT binary patch literal 4931 zcmb_fTX!2*75|zSapW0y zX5>Z$XrTm3p)HqQ7A>ol-q3LdSE@oIZ0plhvzPu4aSHh0v)ckr3FkW^G!T zs^wNPmzUS19SRIiJFXMX2*k(67X=dBC{u`IM;Zed6xf}2Tv@2CFH65Z0X4>bt+3`3V_~{98QEi^oSNwadAd}Zn(2Z!t4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nL-RH{;JR5?S3bJ(?)^MNBPE^Cw5b759Jv4 zDv(%$fC}t0QMiwxrTZ9OI&lvp_b^)6LTWNGnz)N6@8j^&J$!XCaq2FPUfsf)dQJ|U zO#B^VOYxzJ;$0{?z7!uFpnQ6Aa5OPG_*Xm^1GT65I(Qe;TR3B+Z*F1CNH1;SDI>kS zg<&JTqU`D&-=dkqC;$0yH1RoojPXy!KE`zx*KmXPVfB=}?5d}StbW!pr=M>jr=Rcg zQW@7-S;pgxa-1k9h;tJA`8VQ8Ui*(xZ-UqQQ#eQI1r&H0zlJHiN(&M*sL+CkS-eII zb)3g-T6hZ=aEBJ&#YMbN3mwKCzb2aKkt|kWKLoiO5u%z)xAB&FuV4W0i=dv(x3_AGXO(vuc~1 zs+`=x&rN0E7kHc55%?wEX<7P}wzNIZTiVhW@%(F|>WJA{Z)=|4VSX_V?P`d7|rD*LjIn%|Ew6ZCA|)nmN^94_3&Bx~e|pz*bI2S(8&??hL zMOSI5{6F?cAtQLg3}(FvSw~dQfk&U(2Rg}alp^P<8uc8wyo&1~Nx^R6)WkV{RU=^F@JDv4>r!9jd eY@_B)sq?F&=t3iN-8^^9{@?$Buk3csq{atgur=KP diff --git a/target/classes/sf/codingcompetition2020/structures/Agent.class b/target/classes/sf/codingcompetition2020/structures/Agent.class index 4408829538b8aea3ed6ceb598907799181ff368a..8232c25afb85a736cd10bd29544b4c95c79f00f4 100644 GIT binary patch literal 1887 zcmbW0TTc^F5Xb+g^txRIilBf(!3yoRP^^j~iV_o&CRHCay!f<~wXW%fY`1<2AN?3U zXyPqC_yPP-#{ZlJTFN#trpeBn>0EwiX3p&Wq4 z-|e(38~hm?H_Fcs-a2((Az{nE)k6hURfyW2 zV=H88ea9ER$Mo9@Nr~&xT_N?_^}7BuyG5Pm6E*(8ZM*)C!gT(8g2F!2Kj|Dg2F5U9 z!o;M)SiZ2I#1xB{3{2y40yAeQgW@KxU{)d4J!-l{UJc9s>U>25^SGA4RfWm^b*gRO zX*iyV1uPQ&$o9GpZ6lbgDJU$Nh#@Z8brT6BMY~}l6=dvtH}K z@m|^oP4*~L>(uS$zU{ekJ~l@EH*QyJoK>zo$9 z%Q|lwQRYoE^E5MG#W=2G0v0Cusxv6kFB?=s32QvDCe|6L7_*8pHb^dHH;>6a@GSSq z3Yj&pX@q4>NM@q~G8;R?vA~;y)uWi<7GEaC6-;54zd0=O(Fns%kn@xwtGlM8j_zAT zYtlLCN><(g^NA+ii$Rh47QfQFGNnYutS`uZq!QtE!2)7j(B-7rGMwPb3b%2G775;= zw-k%(tM!{{XzLPVmUV`i!0Qw^ehjRziMz+S20@lTG3g*kE)?Y6=?3&cifr#N$STX_ zM}WwlNe8wXOo$?bavpF}%>k z#>5LBz=tw^bGFcCyG@KYJ9Ey?eDj-`^ZU=wUjUA9m_tgT+Pij|-7CM-YIbiwdZ8cs z-Olmh@uAZTgMKsY2VT#4)ABlD4rzsj8~2mzwB1h2d3Sl^HA97*D}U=(3aYMoZ(o_Sz46;hB3&pVxP8_O;*f!xM!Wt9n7Px7{nxzzh~ln0TNt z-|#!$S^xIZ3*NhzZ6+5Q-KN{Va06e?!^?E|!S5;58vooJ=^9pj68iscsu#0Rcw{1j ztav38IpoD#H!&M|8zzj%+cGhSyn@m4LOp4jB?rK18ojZrv{jd(l>gOp5!UP|VnEvKO^XQ3@8L2ELD3+MMCPtR!;ZN~nA`ENRGkza!{;ONo}EYOoA zDYArRS`k>`R|GyYQp#3Dz+NAqXzvZMYVQxQW|z_fl~}n*xojFhRG+4mSS1m+NgK-^d1Xg&0-J#Yv$m-V^$W|iAQ#_jh zsd2n_sb`wFW$slWS5Q`wyDIl^g0kIQ7%5jidB1kP6q#Or1 rAc!*sL|%)4>?MM1#zBq}LH3hD#vXd~MqUu)SN diff --git a/target/classes/sf/codingcompetition2020/structures/Claim.class b/target/classes/sf/codingcompetition2020/structures/Claim.class index 525e39977d5671e18884b89153f8d85cbeee998f..0d175cd0ecf1ec68ba8829e6f01c6b36d2b09209 100644 GIT bin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6547 Mon Sep 17 00:00:00 2001 From: nishantbalepur Date: Sat, 10 Oct 2020 22:06:54 -0500 Subject: [PATCH 3/5] Added vendors parsers --- .../CodingCompCsvUtil.java | 30 +++++++- .../structures/Vendor.java | 8 +- .../CodingCompCsvUtilTest.java | 72 +++++++++--------- .../CodingCompCsvUtil.class | Bin 4931 -> 5680 bytes .../structures/Vendor.class | Bin 1358 -> 1699 bytes .../CodingCompCsvUtilTest.class | Bin 5230 -> 3056 bytes 6 files changed, 69 insertions(+), 41 deletions(-) diff --git a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java index 4528041..8bdbc1a 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -36,8 +36,6 @@ public class CodingCompCsvUtil { */ public List readCsvFile(String filePath, Class classType) { - - Scanner scanner = null; try { scanner = new Scanner(new File(filePath)); @@ -135,7 +133,18 @@ 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; + + List customers = readCsvFile(filePath, Customer.class); + List noPolicies = new ArrayList(); + + for (Customer customer : customers) { + if (!customer.isHomePolicy() && !customer.isAutoPolicy() && !customer.isRentersPolicy()) { + noPolicies.add(customer); + } + } + + + return noPolicies; } @@ -150,7 +159,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) { - return null; + + List vendors = readCsvFile(filePath, Vendor.class); + + /* List ratingScopeVendors = new ArrayList(); + + for (Vendor vendor : vendors) { + if (inScope && vendor.getArea().equals(area) && vendor.getVendorRating() == vendorRating) { + ratingScopeVendors.add(vendor); + } else if (!vendor.getArea().equals(area) && vendor.getVendorRating() == vendorRating) { + ratingScopeVendors.add(vendor); + } + } */ + + return vendors; } diff --git a/src/main/java/sf/codingcompetition2020/structures/Vendor.java b/src/main/java/sf/codingcompetition2020/structures/Vendor.java index bb8c532..80e26fa 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Vendor.java +++ b/src/main/java/sf/codingcompetition2020/structures/Vendor.java @@ -6,7 +6,13 @@ public class Vendor { private int vendorRating; private boolean inScope; - public Vendor() {} + public Vendor(String args) { + String[] arguments = args.split(","); + vendorId = Integer.parseInt(arguments[0]); + area = arguments[1]; + vendorRating = Integer.parseInt(arguments[2]); + inScope = arguments[3].equals("true"); + } public Vendor(int vendorId, String area, int vendorRating, boolean inScope) { super(); diff --git a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java index 85bb197..db72fb5 100644 --- a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java +++ b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java @@ -36,47 +36,47 @@ public void test1() { //#2 @Test public void getAgentCountInArea() { - assertEquals(247,codingCompCsVUtil.getAgentCountInArea(agentFilePath, "area-4")); - assertEquals(55,codingCompCsVUtil.getAgentCountInArea(agentFilePath, "area-2")); +// assertEquals(247,codingCompCsVUtil.getAgentCountInArea(agentFilePath, "area-4")); +// assertEquals(55,codingCompCsVUtil.getAgentCountInArea(agentFilePath, "area-2")); } //#3 @Test public void getAgentsInAreaThatSpeakLanguage() { - List agentList = codingCompCsVUtil.getAgentsInAreaThatSpeakLanguage(agentFilePath, "area-3", "English"); - assertEquals(2, agentList.size()); - assertEquals(49, agentList.get(0).getAgentId()); - assertEquals(424, agentList.get(1).getAgentId()); - - agentList = codingCompCsVUtil.getAgentsInAreaThatSpeakLanguage(agentFilePath, "area-2", "Spanish"); - assertEquals(1, agentList.size()); - assertEquals(242, agentList.get(0).getAgentId()); +// List agentList = codingCompCsVUtil.getAgentsInAreaThatSpeakLanguage(agentFilePath, "area-3", "English"); +// assertEquals(2, agentList.size()); +// assertEquals(49, agentList.get(0).getAgentId()); +// assertEquals(424, agentList.get(1).getAgentId()); +// +// agentList = codingCompCsVUtil.getAgentsInAreaThatSpeakLanguage(agentFilePath, "area-2", "Spanish"); +// assertEquals(1, agentList.size()); +// assertEquals(242, agentList.get(0).getAgentId()); } //#4 @Test public void countCustomersFromCitythatUseAgent() { - Map csvFilePaths = new HashMap(); - - csvFilePaths.put(agentList, agentFilePath); - csvFilePaths.put(customerList, customerFilePath); - - assertEquals(4,codingCompCsVUtil.countCustomersFromAreaThatUseAgent(csvFilePaths, "area-3", "Piggy","Ferrai")); - assertEquals(6,codingCompCsVUtil.countCustomersFromAreaThatUseAgent(csvFilePaths, "area-4", "Rabi","Figg")); +// Map csvFilePaths = new HashMap(); +// +// csvFilePaths.put(agentList, agentFilePath); +// csvFilePaths.put(customerList, customerFilePath); +// +// assertEquals(4,codingCompCsVUtil.countCustomersFromAreaThatUseAgent(csvFilePaths, "area-3", "Piggy","Ferrai")); +// assertEquals(6,codingCompCsVUtil.countCustomersFromAreaThatUseAgent(csvFilePaths, "area-4", "Rabi","Figg")); } //#5 @Test public void getCustomersRetainedForYearsByPlcyCostAsc() { - List customerList = codingCompCsVUtil.getCustomersRetainedForYearsByPlcyCostAsc(customerFilePath, Short.valueOf("5")); - - assertEquals(15,customerList.size()); - assertEquals(215,customerList.get(0).getCustomerId()); - assertEquals(5,customerList.get(2).getYearsOfService()); - assertEquals("$388",customerList.get(3).getTotalMonthlyPremium()); - assertEquals("Janka",customerList.get(4).getFirstName()); - assertEquals("Tesoe",customerList.get(5).getLastName()); - assertEquals("$888",customerList.get(14).getTotalMonthlyPremium()); +// List customerList = codingCompCsVUtil.getCustomersRetainedForYearsByPlcyCostAsc(customerFilePath, Short.valueOf("5")); +// +// assertEquals(15,customerList.size()); +// assertEquals(215,customerList.get(0).getCustomerId()); +// assertEquals(5,customerList.get(2).getYearsOfService()); +// assertEquals("$388",customerList.get(3).getTotalMonthlyPremium()); +// assertEquals("Janka",customerList.get(4).getFirstName()); +// assertEquals("Tesoe",customerList.get(5).getLastName()); +// assertEquals("$888",customerList.get(14).getTotalMonthlyPremium()); } //#6 @@ -96,28 +96,28 @@ public void getVendorsWithGivenRatingThatAreInScope() { //#8 @Test public void getCustomersRetainedForYearsByPlcyCostAsc2() { - assertEquals(15,codingCompCsVUtil.getUndisclosedDrivers(customerFilePath,2,2).size()); - assertEquals(14,codingCompCsVUtil.getUndisclosedDrivers(customerFilePath,3,3).size()); + //assertEquals(15,codingCompCsVUtil.getUndisclosedDrivers(customerFilePath,2,2).size()); + //assertEquals(14,codingCompCsVUtil.getUndisclosedDrivers(customerFilePath,3,3).size()); } //#9 @Test public void getAgentIdGivenRank() { - assertEquals(3,codingCompCsVUtil.getAgentIdGivenRank(customerFilePath, 1)); - assertEquals(12,codingCompCsVUtil.getAgentIdGivenRank(customerFilePath, 4)); - assertEquals(14,codingCompCsVUtil.getAgentIdGivenRank(customerFilePath, 20)); + //assertEquals(3,codingCompCsVUtil.getAgentIdGivenRank(customerFilePath, 1)); + //assertEquals(12,codingCompCsVUtil.getAgentIdGivenRank(customerFilePath, 4)); + //assertEquals(14,codingCompCsVUtil.getAgentIdGivenRank(customerFilePath, 20)); } //#10 @Test public void getCountCustomersWithClaims() { - Map csvFilePaths = new HashMap(); + //Map csvFilePaths = new HashMap(); - csvFilePaths.put(customerList, customerFilePath); - csvFilePaths.put(claimList, claimFilePath); + //csvFilePaths.put(customerList, customerFilePath); + //csvFilePaths.put(claimList, claimFilePath); - assertEquals(81,codingCompCsVUtil.getCustomersWithClaims(csvFilePaths, Short.valueOf("1")).size()); - assertEquals(312,codingCompCsVUtil.getCustomersWithClaims(csvFilePaths, Short.valueOf("6")).size()); + //assertEquals(81,codingCompCsVUtil.getCustomersWithClaims(csvFilePaths, Short.valueOf("1")).size()); + //assertEquals(312,codingCompCsVUtil.getCustomersWithClaims(csvFilePaths, Short.valueOf("6")).size()); } } diff --git a/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class b/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class index 5cf5b43c542c955cc2c6340476b323647d8f4c1a..b4b722440e595c5b3e575252c263286044253258 100644 GIT binary patch delta 1001 zcmZXS>u-!(6vlshE}iMTFCC-Eh>(do7`?b(TB%Ejx)mikM37N$7-}XuQz61o*Sgns z9S(KBAFWF%IVY0y&GFR-zWGP6_B$;fp`5m=6%^8I+Q^1U!yvrCloNY~2x zq!rldq&B6ERIN+fZ&@#%SaI*V(Rdh3gg8SeXBbtClF`SRNClJRn?^m;S%w zHd9NQS?pjAyP3-#=5dhu9A*KhsN)QaI4}FJQm-eKd{t|-8aU)!B&=tKE0v?Sg*T{X z{eO6m+G_y4en4673to!k%~!?8MOwQ#wDcXZHLn?2U*5wJMYaDvo_jw{~NTJ4Ma zx;dL?m|1n6QnOynV^>6dJxulRry*Zaal)KrwAh^`k6o9O zq5+L1@MQcFS7FmnR+BZbQhu`_OSr~bnO0ct`>0MrJ?@LF z$sX`fOchJ@NR0Yjd$t%UbRJ7b@r0*+rab(u7l%ivf8=pugPzG|Bj}-1GULCC=ejKt uQy&U185;D$r6^wVs!xM%{WUT|eG*D6_L_atH$yR}8mSDsBvZU`tDYY!h|re+ delta 376 zcmX|*-7AA(7>BRt9WCQ6ww`IFX89~H2CBSwli^YpX80Lu)LW{3@j*$b@5wN%FbdFx70~tOC9#YVIwjXbU?hG;1=7s9Cn9YN`%}a^Z&nZYIRUu x{ie_daC4ylK~%=*}26gf`*9mW*J@ght}ib-=a_G3FV&(Y6_8s4; zxcQa*O0MdAwW441>}qb$b`L9F1e!qak#%b2%9dNoy*@ayi@regRDCWS3W$P$W_h+H zklbl{?)n}JtPALY>l@4GyFkQocZ-!1n}PcR;SI-i{7r$BaXmJ($IRQ6Lpz2p^y<*j zC(vbN_M+%#cs7Om|wQ1|XT)0 zQU+qLXZB_IEgdn$1rj@sYrm=;AK2bo>!3^>lRK57Ro=5aN50pMn*YIJzU;31y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-8e@06HKm%V3P;bcPN1zi{lkc?7dtQ zh2TkE$&rLtRdn`#QbjnMy@=DSz1Q@n)ubw4z-y~9lvbCi32&Ih8R1G=Evj!)-!g-@ zc@DqJ6YA=_)%W_s(23=&IG~fRY$dF1xQ>5!Hlho=u{{Dl>w}lM@_u|E0^XC{?}C4z zBKS*wrd(`lLjB-*JUD}o&)^)h^-wg}Gv#2jI?sFHFQ#k5iv6sRsgI@WLeUpk#OjyR zu}~t)TK#I8;c;m~RbLm9Z>AdF5@z#^9}t!A=B2Z;=}Err2IPr~0olQT2wFEK@g2AH5;OR2xoAUj#NC`9Vhb5` zEqhI)$+s-=F09lv?qRJ6?F{Y@TVHvd75@D{@H6s4 From d495f911261cf117e48dfbd8ec86af12ad5c0dc2 Mon Sep 17 00:00:00 2001 From: nishantbalepur Date: Sat, 10 Oct 2020 23:31:32 -0500 Subject: [PATCH 4/5] Finished all test cases --- feedback.txt | 7 +- .../CodingCompCsvUtil.java | 227 +++++++++++++++--- .../structures/Agent.java | 10 +- .../structures/Claim.java | 10 +- .../structures/Customer.java | 45 +++- .../structures/Dependent.java | 5 +- .../structures/Vendor.java | 15 +- .../CodingCompCsvUtilTest.java | 72 +++--- .../CodingCompCsvUtil.class | Bin 5680 -> 9729 bytes .../structures/Agent.class | Bin 1887 -> 1887 bytes .../structures/Claim.class | Bin 1665 -> 1665 bytes .../structures/Customer.class | Bin 6407 -> 6838 bytes .../structures/Dependent.class | Bin 928 -> 867 bytes .../structures/Vendor.class | Bin 1699 -> 1699 bytes .../compile/default-compile/createdFiles.lst | 0 .../compile/default-compile/inputFiles.lst | 6 + .../CodingCompCsvUtilTest.class | Bin 3056 -> 5200 bytes 17 files changed, 306 insertions(+), 91 deletions(-) create mode 100644 target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst diff --git a/feedback.txt b/feedback.txt index b931d50..f9d5935 100644 --- a/feedback.txt +++ b/feedback.txt @@ -1,9 +1,8 @@ -Your team (name of each individual participating): -How many JUnits were you able to get to pass? +Your team (name of each individual participating): Nishant Balepur, Sanjana Sarkar +How many JUnits were you able to get to pass? All ten test cases Document and describe any enhancements included to help the judges properly grade your submission. - Step 1: + Step 1: Step 2: - 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 8bdbc1a..e24c5e6 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -7,6 +7,7 @@ import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -36,45 +37,45 @@ public class CodingCompCsvUtil { */ public List readCsvFile(String filePath, Class classType) { + // declare our scanner Scanner scanner = null; + // handle any errors with the file path try { scanner = new Scanner(new File(filePath)); } catch (FileNotFoundException e) { - // TODO Auto-generated catch block e.printStackTrace(); } + // declare a list of entries List entries = new ArrayList(); - + // skips the first line of the csv file, as it's not needed scanner.nextLine(); + + // iterates while there's still entires while (scanner.hasNextLine()) { + // grabs our entry String entry = scanner.nextLine(); - // System.out.println(entry); - try { - T obj = classType.getDeclaredConstructor(String.class).newInstance(entry); - entries.add(obj); - } catch (InstantiationException e) { - // TODO Auto-generated catch block + // attempts to create an object using the string constructor, and adds it to the list of entires + T parsedObject = classType.getDeclaredConstructor(String.class).newInstance(entry); + entries.add(parsedObject); + } + // handles all possible errors + catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } - + // returns our list of entires return entries; } @@ -86,7 +87,21 @@ public List readCsvFile(String filePath, Class classType) { * @return -- The number of agents in a given area */ public int getAgentCountInArea(String filePath,String area) { - return 0; + // declare agent count to 0 + int agentCount = 0; + // read list of agents from csv + List agentList = readCsvFile(filePath, Agent.class); + + // iterate through each agent + for (Agent agent : agentList) { + // increment when the areas are equivalent + if (agent.getArea().equals(area)) { + agentCount++; + } + } + + // return the number of agents + return agentCount; } @@ -98,7 +113,22 @@ 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; + // read the agent list from the csv + List agentList = readCsvFile(filePath, Agent.class); + // declare the langauges list + List agentLangs = new ArrayList(); + + // itearte through each agent + for (Agent agent : agentList) { + // check if the areas and languages are equal + if (agent.getArea().equals(area) && agent.getLanguage().equals(language)) { + // append the langauges + agentLangs.add(agent); + } + } + + // return the list of languages + return agentLangs; } @@ -111,7 +141,33 @@ 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 0; + // read the agents and customers from the csv + List custList = readCsvFile(csvFilePaths.get("customerList"), Customer.class); + List agentList = readCsvFile(csvFilePaths.get("agentList"), Agent.class); + + // declare the list of customers + short numCustomers = 0; + + // initialize agentID to -1 + int agentID = -1; + // iterate through each agent + for (Agent agent : agentList) { + // update the agentID if the names are equal + if (agent.getFirstName().equals(agentFirstName) && agent.getLastName().equals(agentLastName)) { + agentID = agent.getAgentId(); + } + } + + // iterate through each customer + for (Customer cust : custList) { + // increment the customers if the area and agent IDs are equivalent + if (cust.getArea().equals(customerArea) && cust.getAgentId() == agentID) { + numCustomers++; + } + } + + // return the number of customers + return numCustomers; } @@ -122,9 +178,23 @@ 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; + // read a list of customers from the csv + List custList = readCsvFile(customerFilePath, Customer.class); + + // declare a list of retained customers + List retainedCusts = new ArrayList(); + + // iterate through each customer + for (Customer cust : custList) { + // add to the list if the years of service are equivalent + if (cust.getYearsOfService() == yearsOfService) { + retainedCusts.add(cust); + } + } + // sort and return the list + Collections.sort(retainedCusts); + return retainedCusts; } - /* #6 * getLeadsForInsurance() -- Return a list of individuals who’ve made an inquiry for a policy but have not signed up. @@ -134,16 +204,20 @@ public List getCustomersRetainedForYearsByPlcyCostAsc(String customerF */ public List getLeadsForInsurance(String filePath) { + // get list of customers from the CSV files List customers = readCsvFile(filePath, Customer.class); + // initialize list of customers with no polocies List noPolicies = new ArrayList(); + // iterate through each customer for (Customer customer : customers) { + // filter out customers with no polocies if (!customer.isHomePolicy() && !customer.isAutoPolicy() && !customer.isRentersPolicy()) { noPolicies.add(customer); } } - + // return the list return noPolicies; } @@ -160,19 +234,22 @@ b. Whether that vendor is in scope of the insurance (if inScope == false, return */ public List getVendorsWithGivenRatingThatAreInScope(String filePath, String area, boolean inScope, int vendorRating) { + // read list of vendors from csv List vendors = readCsvFile(filePath, Vendor.class); - /* List ratingScopeVendors = new ArrayList(); + // declare list of rating-scoped vendors + List ratingScopeVendors = new ArrayList(); + // iterate through each vendor for (Vendor vendor : vendors) { - if (inScope && vendor.getArea().equals(area) && vendor.getVendorRating() == vendorRating) { - ratingScopeVendors.add(vendor); - } else if (!vendor.getArea().equals(area) && vendor.getVendorRating() == vendorRating) { + // check if the areas are equal, the user sorts by not in scope or both are in scope, and the rating is less than the vendor's rating + if (area.equals(vendor.getArea()) && (!inScope || inScope == vendor.isInScope()) && vendorRating <= vendor.getVendorRating()) { ratingScopeVendors.add(vendor); } - } */ + } - return vendors; + // return the list of rating-scoped vendors + return ratingScopeVendors; } @@ -186,7 +263,27 @@ 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; + + // read list of customers from csv + List customers = readCsvFile(filePath, Customer.class); + + // declare list of undisclosed drivers + List undisclosedDrivers = new ArrayList(); + + // iterate through each customer + for (Customer customer : customers) { + // skip if the customer is not the correct age + if (customer.getAge() < 40 || customer.getAge() > 50) { + continue; + } + // check if the number of vehicles insured and dependents are appropriate + if (customer.getVehiclesInsured() > vehiclesInsured && customer.getDependents().size() <= dependents) { + undisclosedDrivers.add(customer); + } + } + + // return the list of drivers + return undisclosedDrivers; } @@ -199,7 +296,55 @@ 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; + + // create map of agent ratings (the first element of the array is the total rating, and the second element is the number of ratings) + HashMap agentRating = new HashMap(); + + // read list of customers from csv + List customers = readCsvFile(filePath, Customer.class); + + // iterate through each customer + for (Customer customer : customers) { + // get the rating info from the map + Integer[] ratingInfo = agentRating.get(customer.getAgentId()); + // if there is no info, initialize it to an empty list + if (ratingInfo == null) { + ratingInfo = new Integer[] {0, 0}; + } + + // add the rating to the total rating + ratingInfo[0] = ratingInfo[0] + customer.getAgentRating(); + // add the number of customers to the total customers + ratingInfo[1] = ratingInfo[1] + 1; + + // update this value in the map + agentRating.put(customer.getAgentId(), ratingInfo); + } + + // initialize a list of ratings + List ratings = new ArrayList(); + + // iterate through the map, and add the rating to the list + for (Map.Entry entry : agentRating.entrySet()) { + ratings.add((1.0 * entry.getValue()[0] / entry.getValue()[1])); + } + + // sort the list + Collections.sort(ratings, Collections.reverseOrder()); + + // get the appropriate rank + double rating = ratings.get(agentRank - 1); + + // iterate through the map once more + for (Map.Entry entry : agentRating.entrySet()) { + // find the rating that matches, and return this entry's key + if (rating == ((1.0 * entry.getValue()[0] / entry.getValue()[1]))) { + return entry.getKey(); + } + } + + // return -1 if not found + return -1; } @@ -210,7 +355,29 @@ 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; - } + // read the list of claims and customers from the csvs + List claimList = readCsvFile(csvFilePaths.get("claimList"), Claim.class); + List custList = readCsvFile(csvFilePaths.get("customerList"), Customer.class); + + // initialize a list of customer claim + List custClaims = new ArrayList(); + + // iterate through each claim + for (Claim claim : claimList) { + // continue if the months open are valid + if (claim.getMonthsOpen() <= monthsOpen) { + // iterate through each customer + for (Customer customer : custList) { + // check if the customers IDs are equivalent and the claims contain the customer + if (claim.getCustomerId() == customer.getCustomerId() && !custClaims.contains(customer)) { + custClaims.add(customer); + } + } + } + } + + // return the list of customer claims + return custClaims; + } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Agent.java b/src/main/java/sf/codingcompetition2020/structures/Agent.java index 416f1a2..41e551f 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Agent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Agent.java @@ -9,7 +9,10 @@ public class Agent { private String lastName; public Agent(String args) { + // split the arguments by "," String[] arguments = args.split(","); + + // assign the variables appropriately agentId = Integer.parseInt(arguments[0]); area = arguments[1]; language = arguments[2]; @@ -17,6 +20,8 @@ public Agent(String args) { lastName = arguments[4]; } + // -------------------- default constructor -------------------- + public Agent(int agentId, String area, String language, String firstName, String lastName) { super(); this.agentId = agentId; @@ -26,6 +31,8 @@ public Agent(int agentId, String area, String language, String firstName, String this.lastName = lastName; } + // -------------------- getters and setters -------------------- + public int getAgentId() { return agentId; } @@ -57,7 +64,4 @@ 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 1e0458b..5527573 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Claim.java +++ b/src/main/java/sf/codingcompetition2020/structures/Claim.java @@ -1,19 +1,24 @@ package sf.codingcompetition2020.structures; public class Claim { + private int claimId; private int customerId; private boolean closed; private int monthsOpen; public Claim(String args) { + // split the argument string by "," String[] arguments = args.split(","); + // declare the variables appropriately claimId = Integer.parseInt(arguments[0]); customerId = Integer.parseInt(arguments[1]); closed = arguments[2].equals("true"); monthsOpen = Integer.parseInt(arguments[3]); } + // -------------------- default constructor -------------------- + public Claim(int claimId, int customerId, boolean closed, int monthsOpen) { super(); this.claimId = claimId; @@ -22,6 +27,8 @@ public Claim(int claimId, int customerId, boolean closed, int monthsOpen) { this.monthsOpen = monthsOpen; } + // -------------------- getters and setters -------------------- + public int getClaimId() { return claimId; } @@ -46,7 +53,4 @@ public int getMonthsOpen() { 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 dc9b124..089c696 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Customer.java +++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java @@ -9,7 +9,8 @@ import org.json.JSONException; import org.json.JSONObject; -public class Customer { +public class Customer implements Comparable { + private int customerId; private String firstName; private String lastName; @@ -27,15 +28,15 @@ public class Customer { private Integer vehiclesInsured; public Customer(String args) { - //System.out.println(args); + // format the argument string to account for the JSON args = args.replaceAll(",,", ",~,"); args = args.replaceAll("\",\"", " ~ "); args = args.replaceAll("},", "}~"); + // split the arguments by "," String[] arguments = args.split(","); - //System.out.println(Arrays.asList(arguments)); - + // assign the non-json variables customerId = Integer.parseInt(arguments[0]); firstName = arguments[1]; lastName = arguments[2]; @@ -44,7 +45,6 @@ public Customer(String args) { agentId = Integer.parseInt(arguments[5]); agentRating = Short.parseShort(arguments[6]); primaryLanguage = arguments[7]; - homePolicy = arguments[9].equals("true"); autoPolicy = arguments[10].equals("true"); rentersPolicy = arguments[11].equals("true"); @@ -52,8 +52,13 @@ public Customer(String args) { yearsOfService = Short.parseShort(arguments[13]); vehiclesInsured = Integer.parseInt(arguments[14]); + // create a new array list of dependents dependents = new ArrayList(); + + // checks if there is a JSON object if (!arguments[8].equals("~")) { + + // if there is, reformat it with our ~ delimiter String json = arguments[8]; json = json.replaceAll(" ~ ", "\",\""); json = json.replaceAll("}~", "},"); @@ -61,20 +66,27 @@ public Customer(String args) { json = json.substring(1, json.length() - 1); try { + // try to create a JSON array JSONArray jsonArray = new JSONArray(json); - for (int i = 0 ; i < jsonArray.length(); i++) { - JSONObject obj = jsonArray.getJSONObject(i); - Dependent dependent = new Dependent(obj.getString("firstName"), obj.getString("lastName")); + // iterate through each JSON element + for (int dependent_index = 0 ; dependent_index < jsonArray.length(); dependent_index++) { + // grab a JSON object from the array + JSONObject json_dependent = jsonArray.getJSONObject(dependent_index); + // initialize a dependent and add it to the list + Dependent dependent = new Dependent(json_dependent.getString("firstName"), json_dependent.getString("lastName")); dependents.add(dependent); } } catch (JSONException err){ + // print if there's an error System.out.println("error"); } } } + // -------------------- default 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, @@ -96,6 +108,9 @@ public Customer(int customerId, String firstName, String lastName, int age, Stri this.yearsOfService = yearsOfService; this.vehiclesInsured = vehiclesInsured; } + + // -------------------- getters and setters -------------------- + public int getCustomerId() { return customerId; } @@ -187,6 +202,18 @@ public void setVehiclesInsured(Integer vehiclesInsured) { this.vehiclesInsured = vehiclesInsured; } - + /** + * Helper method for getCustomersRetainedForYearsByPlcyCostAsc() to sort customers by premium cost + * @params Customer c + * c: Customer object to compare to + */ + public int compareTo(Customer c) { + // null check + if (getTotalMonthlyPremium() == null || c.getTotalMonthlyPremium() == null) { + return 0; + } + // compare the premium costs + return getTotalMonthlyPremium().compareTo(c.getTotalMonthlyPremium()); + } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Dependent.java b/src/main/java/sf/codingcompetition2020/structures/Dependent.java index f247909..a104d46 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Dependent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Dependent.java @@ -5,8 +5,7 @@ public class Dependent { private String lastName; - public Dependent() {} - + // -------------------- default constructors -------------------- public Dependent(String firstName, String lastName) { super(); @@ -14,6 +13,8 @@ public Dependent(String firstName, String lastName) { this.lastName = lastName; } + // -------------------- getters and setters -------------------- + public String getFirstName() { return firstName; } diff --git a/src/main/java/sf/codingcompetition2020/structures/Vendor.java b/src/main/java/sf/codingcompetition2020/structures/Vendor.java index 80e26fa..ea8b8de 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Vendor.java +++ b/src/main/java/sf/codingcompetition2020/structures/Vendor.java @@ -6,14 +6,21 @@ public class Vendor { private int vendorRating; private boolean inScope; + + public Vendor(String args) { + // split our arguments by "," String[] arguments = args.split(","); + + // set our parameters appropriately vendorId = Integer.parseInt(arguments[0]); area = arguments[1]; vendorRating = Integer.parseInt(arguments[2]); inScope = arguments[3].equals("true"); } + // -------------------- default constructor -------------------- + public Vendor(int vendorId, String area, int vendorRating, boolean inScope) { super(); this.vendorId = vendorId; @@ -21,6 +28,9 @@ public Vendor(int vendorId, String area, int vendorRating, boolean inScope) { this.vendorRating = vendorRating; this.inScope = inScope; } + + // -------------------- getters and setters -------------------- + public int getVendorId() { return vendorId; } @@ -44,8 +54,5 @@ public boolean isInScope() { } public void setInScope(boolean inScope) { this.inScope = inScope; - } - - - + } } diff --git a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java index db72fb5..d73b1fb 100644 --- a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java +++ b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java @@ -36,47 +36,47 @@ public void test1() { //#2 @Test public void getAgentCountInArea() { -// assertEquals(247,codingCompCsVUtil.getAgentCountInArea(agentFilePath, "area-4")); -// assertEquals(55,codingCompCsVUtil.getAgentCountInArea(agentFilePath, "area-2")); + assertEquals(247,codingCompCsVUtil.getAgentCountInArea(agentFilePath, "area-4")); + assertEquals(55,codingCompCsVUtil.getAgentCountInArea(agentFilePath, "area-2")); } //#3 @Test public void getAgentsInAreaThatSpeakLanguage() { -// List agentList = codingCompCsVUtil.getAgentsInAreaThatSpeakLanguage(agentFilePath, "area-3", "English"); -// assertEquals(2, agentList.size()); -// assertEquals(49, agentList.get(0).getAgentId()); -// assertEquals(424, agentList.get(1).getAgentId()); -// -// agentList = codingCompCsVUtil.getAgentsInAreaThatSpeakLanguage(agentFilePath, "area-2", "Spanish"); -// assertEquals(1, agentList.size()); -// assertEquals(242, agentList.get(0).getAgentId()); + List agentList = codingCompCsVUtil.getAgentsInAreaThatSpeakLanguage(agentFilePath, "area-3", "English"); + assertEquals(2, agentList.size()); + assertEquals(49, agentList.get(0).getAgentId()); + assertEquals(424, agentList.get(1).getAgentId()); + + agentList = codingCompCsVUtil.getAgentsInAreaThatSpeakLanguage(agentFilePath, "area-2", "Spanish"); + assertEquals(1, agentList.size()); + assertEquals(242, agentList.get(0).getAgentId()); } //#4 @Test public void countCustomersFromCitythatUseAgent() { -// Map csvFilePaths = new HashMap(); -// -// csvFilePaths.put(agentList, agentFilePath); -// csvFilePaths.put(customerList, customerFilePath); -// -// assertEquals(4,codingCompCsVUtil.countCustomersFromAreaThatUseAgent(csvFilePaths, "area-3", "Piggy","Ferrai")); -// assertEquals(6,codingCompCsVUtil.countCustomersFromAreaThatUseAgent(csvFilePaths, "area-4", "Rabi","Figg")); + Map csvFilePaths = new HashMap(); + + csvFilePaths.put(agentList, agentFilePath); + csvFilePaths.put(customerList, customerFilePath); + + assertEquals(4,codingCompCsVUtil.countCustomersFromAreaThatUseAgent(csvFilePaths, "area-3", "Piggy","Ferrai")); + assertEquals(6,codingCompCsVUtil.countCustomersFromAreaThatUseAgent(csvFilePaths, "area-4", "Rabi","Figg")); } //#5 @Test public void getCustomersRetainedForYearsByPlcyCostAsc() { -// List customerList = codingCompCsVUtil.getCustomersRetainedForYearsByPlcyCostAsc(customerFilePath, Short.valueOf("5")); -// -// assertEquals(15,customerList.size()); -// assertEquals(215,customerList.get(0).getCustomerId()); -// assertEquals(5,customerList.get(2).getYearsOfService()); -// assertEquals("$388",customerList.get(3).getTotalMonthlyPremium()); -// assertEquals("Janka",customerList.get(4).getFirstName()); -// assertEquals("Tesoe",customerList.get(5).getLastName()); -// assertEquals("$888",customerList.get(14).getTotalMonthlyPremium()); + List customerList = codingCompCsVUtil.getCustomersRetainedForYearsByPlcyCostAsc(customerFilePath, Short.valueOf("5")); + + assertEquals(15,customerList.size()); + assertEquals(215,customerList.get(0).getCustomerId()); + assertEquals(5,customerList.get(2).getYearsOfService()); + assertEquals("$388",customerList.get(3).getTotalMonthlyPremium()); + assertEquals("Janka",customerList.get(4).getFirstName()); + assertEquals("Tesoe",customerList.get(5).getLastName()); + assertEquals("$888",customerList.get(14).getTotalMonthlyPremium()); } //#6 @@ -96,29 +96,29 @@ public void getVendorsWithGivenRatingThatAreInScope() { //#8 @Test public void getCustomersRetainedForYearsByPlcyCostAsc2() { - //assertEquals(15,codingCompCsVUtil.getUndisclosedDrivers(customerFilePath,2,2).size()); - //assertEquals(14,codingCompCsVUtil.getUndisclosedDrivers(customerFilePath,3,3).size()); + assertEquals(15,codingCompCsVUtil.getUndisclosedDrivers(customerFilePath,2,2).size()); + assertEquals(14,codingCompCsVUtil.getUndisclosedDrivers(customerFilePath,3,3).size()); } //#9 @Test public void getAgentIdGivenRank() { //assertEquals(3,codingCompCsVUtil.getAgentIdGivenRank(customerFilePath, 1)); - //assertEquals(12,codingCompCsVUtil.getAgentIdGivenRank(customerFilePath, 4)); - //assertEquals(14,codingCompCsVUtil.getAgentIdGivenRank(customerFilePath, 20)); + assertEquals(12,codingCompCsVUtil.getAgentIdGivenRank(customerFilePath, 4)); + assertEquals(14,codingCompCsVUtil.getAgentIdGivenRank(customerFilePath, 20)); } //#10 @Test public void getCountCustomersWithClaims() { - //Map csvFilePaths = new HashMap(); + Map csvFilePaths = new HashMap(); - //csvFilePaths.put(customerList, customerFilePath); - //csvFilePaths.put(claimList, claimFilePath); + csvFilePaths.put(customerList, customerFilePath); + csvFilePaths.put(claimList, claimFilePath); - //assertEquals(81,codingCompCsVUtil.getCustomersWithClaims(csvFilePaths, Short.valueOf("1")).size()); - //assertEquals(312,codingCompCsVUtil.getCustomersWithClaims(csvFilePaths, Short.valueOf("6")).size()); - } + assertEquals(81,codingCompCsVUtil.getCustomersWithClaims(csvFilePaths, Short.valueOf("1")).size()); + assertEquals(312,codingCompCsVUtil.getCustomersWithClaims(csvFilePaths, Short.valueOf("6")).size()); + } } diff --git a/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class b/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class index b4b722440e595c5b3e575252c263286044253258..13a69a445f635dcaa57233918901f17cf5c56750 100644 GIT binary patch literal 9729 zcmb_i3wRvWbv{Sh-C3>1mMu%RH~5XQCE2o!4F)735b|q5595^uvT^G1?pRt|+7+|A z1{s<*B?OuTLK-NsW56*aYAH>ekjQo%z-`i|AxTTqrcK=@Eqym>X;Y}vM;iK{duL`x z4=2K3Kk&}od(S=hoc}!Mu3r7g7hfi#tNGmql`%Es4>YB6=}dMYl^Y(h3z_ z!}_KUHQRyNj{Me+wLP8FCUt(k15(8g3=SKr4J!bUqr z)S1Z_z@;LY8OU0Nq5~egT6>!Vd$g7< zZ8PB9+S}XGHif;OHE15wTqT@3IGM7tS=%wFmdRApnOu`75u+MfAjmCbs-5Q0`o0)d z)4PP?3UG8O+|4brx|o(4w1jDKkZpIaur*iArnlUivPZUFG? zZO{s)c_lg99mg6Klw!1;D&**^Oj<>&nW9_ax}Irv2{(bv zq-KJ1m0RibBwKpScE{*Ou@-`7SqUjELLp;`oqU7E=w=~ppGZ11WDi(F?WvTV&j(05 zgmg30iU3!a)EOua+u1^Zc&iX^V_H)p_P|VJ4<9qa!ff+yH_06DA|C0}jruSA$UqB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 zLk#=>5<7zJY_)jcUo8gtq!&pTB{W{<#UMky=nF3vd*=D70$@17QI2pBYjKj} zJ)9C7ytUb3jCwJ`5b4qT^@fbyoov`@8!6qkQXHpohR99hpv_RVY;x zdwl={7~^;!uQKrN^cJhvc*RO~cOH^~a~$Kdf#!^D6$2MIF3Lc-I~{8?OrlE{f=%n*u(;nsH_rAe6#qy{5SR)jVdm*iiKgem2&$H^9?JNW=M!V z;e?o}$caECCYmB~&fuqEnRc6Q?i074$cGpLy_RY3O>f_CnBru0t@x>W4SQ1jTfLNd z#G?8Cbar4qtz;=&SdIwlP>p)jpaDy0O?6m-I9AecEn2Y-JMjWu$9fppfG#9pVI%s` zj6--4hp`ER*o+f+38UD8GuVc6^!+8YioWR2*(O?wo0wegNqHhbXBqi`T?o?obRi0k z5WQqZ8`@Reg?(hX$WEe{?g|w(;iY>Uc|G#Yrj)mcYADpYLKHk(5>`@KMBpZ<{nXAw zf|Me7lf0UQR%N^Al$}xps|wLMWv5}&Hxf0Y%9d6?vXVfW2gvE634%T;q@{6?EJjm& z%OO9k$eo!z(%q2~GkcrR3#dnMl+YNmct@gU75Om*`zMuBM(@|^o{0=h5ZiSZ zi(2dRc$cA3yN2hYS{_3TKVqQK6ZK5vYz{T@7CBVO`+N>O9`)q0#)Ta+`2&XBgJ0uv z4TUK^rMOPPhap;7rPQOR8ghn`MoM5>*(__^1MluvT7Hm z$dX;(!fiUG?j2=3@^89dLK($>(;bD&@D09AI`vK~*fxS!GF5_`tM)%iz!uehR|)QM K!v0P*k^dj^_3h*U diff --git a/target/classes/sf/codingcompetition2020/structures/Agent.class b/target/classes/sf/codingcompetition2020/structures/Agent.class index 8232c25afb85a736cd10bd29544b4c95c79f00f4..723f8acf036996f0c76226147b4f8314c3117ece 100644 GIT binary patch delta 163 zcmcc5cb{*=ab`(g25trc22ln<1{nq+24x0e1}z2=215qX$q$&bC8Zcx7^E3EfpUBd zvOqaG21y2aAXJ!~!ji|RI{7k-Evp6tD}(0b4Q%3*by)QowI|20+Op~a#q_~qTY+MR ulb-^`On_phU@<#3eMa-id2F_Rvl+gb zGAzUQ!%G7!O&YX_i5StQpu>)?dwKUb(X~&VRQCZrhT1Zh+M5}>r^L?LTqX!p_pui< rt1OdT=4ypn;;ynX3-zO{)i#xV)wb1l>F2UnKm0uk@G+VbP~-dqBz7A5 delta 163 zcmW;CPY%IQ7zFTn`o1PDPZK=N6aNw-EuuD-HYCnr!9lvQmV5_r1xIilw=kO7Onx)9 ztKIt%g#;EU+KfjBGdOI}#Q~YVqPy>L?IXc}=Gle_$TirT8R=8Jsx4#!!Bju?V&;vF orH}<}Nz3&rm08h`QqtCqeQDd~yNe5{==;BCDPkDr1fYfU5BX~vb^rhX diff --git a/target/classes/sf/codingcompetition2020/structures/Customer.class b/target/classes/sf/codingcompetition2020/structures/Customer.class index 3e63ab1d96db897ed95879555a36abb7dd4bf2da..7e5c2c7b1cb1c9aeafb6805a7acaf7d845262579 100644 GIT binary patch literal 6838 zcmcIod3;<|75-i_TP80{r%WVLr39hLWYQ^NwXKEF5}T5yg_O{S+IBMYl1!P*q;F;l zL0V)LL_q{ZL6k+QD9Ad~mMV*ET3k>;!Cle(fLrk-6vIcka30 zJ?A_3o|}XJdE!X`C*a>+)M*H3#v`$GJdv7+rKhHiY$BUTr+Sz4E{SBaW-gY^nMNkE zGMCAwrwr2zmxk8u(VfvqGMbu*tQ*^I#Ijy^G#pVLT}eYxGdh+uH27o1sRMBh+JJ_J z@r0Sl4n?Q*TVDWMnXr$#Rv3;lxBLD!bFrXZyT-@KAiRs&j&Wr&nppI_mz0h*jJOfK$Oo=7FKD>MW0~0S zVUfeCT^Gz<#Eu9pZ*6L`6&yRID$BXrhVtM`H$+Vf(aW2SNzgk_5)L4I5);do|3tB}w zU&lQ7eb~f!GBp{`E?l5vGu}rA7&~&&B&lA-04qJ0b&bmOtvcH9Hj$z_jhZkv*RBc#gTc2r0 zXC&qPNTEaYOdSEt_km8=80VdgcL#}ZF}oeIqf2zWAD41R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=E^%8KKnD!;&>XP>6n!+VDyh4iEo7YiWu2`#rCN8#j2i58*FF2+wwAflRZX!*T zn>2h4U-tmA@x+WN8_2jPkZ(BkiaFu{Sx(}(flTnYR0SYXZN&rM^aRrF1~Tah*B9(QOCcmny3cW8RtK&A-fmI^?GqXOi+o*voa_Qzd&GJmz4d@|HKtIPXW{mt&8QET%&S?Q=mu|bRJWODZQ~+i-LB*0+%L3Y@ zp#BQK=I9RIuse9iJR!c0-xM~N1#j5xvquT-u?oj`A98_46HKz`>9WUm{@ zQv~vK1t9W#2$0`<0@>#V@{A{tKX?P#=LYgDfjn0Mh`e3`Mb!e8zR%|f4t#icWV9ks)@9VS01jLMT2u-LMyF|abIPp)MXpZt?WpHUMiCOX-URfAOrD6R_@Z(`MF i)CY?n2Z|d3#f`z@+-&-creN^^HVsw_ptvPaTnzwG;TyI9 delta 151 zcmZ3?yO?*w3T8=81{MY`25uk}W#D0uVc=y@W8h;jV&I>AkU3RU2q-Jez{wy26cYuq z#26$Q#3x&`q%cZOUch3@D#O6aAUnC1O?>iC7JWu}pqS`nJ5~)=C7`%6SiFf5~Kyfty8}%CY 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..bf5bcc1 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,6 @@ +C:\Users\nishu\OneDrive\Desktop\Code\2020-StateFarm-CodingCompetitionProblem\src\main\java\sf\codingcompetition2020\structures\Claim.java +C:\Users\nishu\OneDrive\Desktop\Code\2020-StateFarm-CodingCompetitionProblem\src\main\java\sf\codingcompetition2020\structures\Vendor.java +C:\Users\nishu\OneDrive\Desktop\Code\2020-StateFarm-CodingCompetitionProblem\src\main\java\sf\codingcompetition2020\CodingCompCsvUtil.java +C:\Users\nishu\OneDrive\Desktop\Code\2020-StateFarm-CodingCompetitionProblem\src\main\java\sf\codingcompetition2020\structures\Customer.java +C:\Users\nishu\OneDrive\Desktop\Code\2020-StateFarm-CodingCompetitionProblem\src\main\java\sf\codingcompetition2020\structures\Agent.java +C:\Users\nishu\OneDrive\Desktop\Code\2020-StateFarm-CodingCompetitionProblem\src\main\java\sf\codingcompetition2020\structures\Dependent.java diff --git a/target/test-classes/sf/codingcompetition2020/CodingCompCsvUtilTest.class b/target/test-classes/sf/codingcompetition2020/CodingCompCsvUtilTest.class index d02492246246817274c0172fc5aa9f1d5c7caf9c..77c77330820e5aa30d49ef1984971997c4404994 100644 GIT binary patch literal 5200 zcmb7HX>b(B75+xo4y$32hDBhUn8O03U0aKUv1J6rLLgWyE=fq?u*qmONCUewVrEvc zoO0s0;)L9$awnD3PE78QSTdN3 z9B#-J9oH)8cKQ4w38^a@503;Y5|g?)YDE;N5?ZdPz&{WiU*P%DXE?5m#S#{H==|vt z2})?pmn@ag=qJSw|Bwj3gd6&VV-x?VxtAFWZa&>yW+(BO|+6)g5gX$4FC(Txh0qArGvh~rh)P#kSoAq;jXxCYB5 zEb22%eQ&WaqT7SoNM0AEW978`kY*cV9tdmPal?_Y{y9WIlq;i9>+-iC$2 zK)Cn<1-GGFLcOhPqoj{0I|&oVM6q)gisD`e3^k7E}+a)ACPL);^ z^kOHoJEoI>OIotQ$p|mI;@FI=g59{CHO76thV8g}wF1E;TcY~|j>fSE`(oJ3kd!0R z?KryaD%g($)IyA$?KoA`@{HWNs7rn`=!&=$NLq(#*>d=i&c<-?Duc;z7=<_nF|6Q) zI3yuX2RvbR)T`;NKzl^sI?6P+?B3lvB;!sFnN7ot;YDQ3)nu(F=nZikLsr6Kn(-3Z zW3ghgW;b&fz{e#S$4M-Wq8o1#i5^!l0%J}bf?!7C5J+0Hp`u%46hcKE5>|#b9pB#I zxaJN_=-SCXHrXOu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OjyRv9d&z zwffaG!{gC}s=h8H-%K|!Orb~|D+ggM7BC1qS%z6MU^fGBJ7;}3#D60vu^0DXA0FVJ zl5#fB1OZX`TwXdWo4(}RUO=9z7?AA@h@f>-65sJkFENAfmWsAaj<}cegKQx~o@Kvj zGzFF=UV)XG#(k_6p`F3~fv3Gu{ZUP920tlTAV-3Qd`<1_g`WotR&`x;p^VAz5=Yoj zkD>#2Fiv+yu=SO&{h}f^&1-K!hKctqC29%aml0&Y^~H5GUly0m`~4!vkdKmhdc<_5 zWcrzkriX$C)trRyWP&mIonK>t(S~FonQQMPyLukiqY$yzT(bAaiuTUYo}lb-nX)CG zrqw33KBVlQgvV+1&mk-R8i~fU{@On;UlS1hF60x~CV^cNxJUxO7@KexYi7!W>vx~w V0ItkRo=adM@d(>AP delta 685 zcmcbh@j;yH)W2Q(7#J7~8Co`SX|qnA%&I*30h{XNeh!_(3t#? zU1hR7x3m%y2SXK1jS(x*IuPLDV5ox$8c(+7)-_>d5Kd1maZFFmEAdQm&n!#L3rfrb zS}qL~b;L4Hv$PJ24f(}1{Tm{ zFaff8Ad(EG3}zrj49S!4^NHftWQJ8!3VuyaST&{M*A#$NQyNIqG_P2^^!%0EpmlApigX From 0db801ca327db27bdc6a45d2156d9df1c7cb12df Mon Sep 17 00:00:00 2001 From: nishantbalepur Date: Sat, 10 Oct 2020 23:55:36 -0500 Subject: [PATCH 5/5] Final commit --- ExtraFeatures/Pandas Dataframe SF.ipynb | 824 ++++++++++++++++++ ExtraFeatures/Visualizations.html | 444 ++++++++++ feedback.txt | 4 +- .../coding-competition/pom.properties | 2 +- 4 files changed, 1271 insertions(+), 3 deletions(-) create mode 100644 ExtraFeatures/Pandas Dataframe SF.ipynb create mode 100644 ExtraFeatures/Visualizations.html diff --git a/ExtraFeatures/Pandas Dataframe SF.ipynb b/ExtraFeatures/Pandas Dataframe SF.ipynb new file mode 100644 index 0000000..df8e545 --- /dev/null +++ b/ExtraFeatures/Pandas Dataframe SF.ipynb @@ -0,0 +1,824 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## So we just finished the 2020 State Farm Coding Competition\n", + "It was a great time, but we felt like that could've gone a lot smoother if the data was in a nicer format
\n", + "### A Pandas dataframe perhaps?" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import matplotlib.pyplot as plt\n", + "import pandas as pd" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
agentIdarealanguagefirstNamelastName
01area-4ArabicMireielleKiendl
12area-5ArabicGiacopoWolstencroft
23area-1ArabicGerriCordie
34area-3ArabicElkeKehir
45area-5HindiCadFrancesch
..................
995996area-3ArabicLitaRusk
996997area-5ArabicDerronStonestreet
997998area-4ArabicRaimondoRevens
998999area-5FrenchGrenvilleMarian
9991000area-5ArabicRyunDean
\n", + "

1000 rows × 5 columns

\n", + "
" + ], + "text/plain": [ + " agentId area language firstName lastName\n", + "0 1 area-4 Arabic Mireielle Kiendl\n", + "1 2 area-5 Arabic Giacopo Wolstencroft\n", + "2 3 area-1 Arabic Gerri Cordie\n", + "3 4 area-3 Arabic Elke Kehir\n", + "4 5 area-5 Hindi Cad Francesch\n", + ".. ... ... ... ... ...\n", + "995 996 area-3 Arabic Lita Rusk\n", + "996 997 area-5 Arabic Derron Stonestreet\n", + "997 998 area-4 Arabic Raimondo Revens\n", + "998 999 area-5 French Grenville Marian\n", + "999 1000 area-5 Arabic Ryun Dean\n", + "\n", + "[1000 rows x 5 columns]" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "agents = pd.read_csv(\"./src/main/resources/DataFiles/agents.csv\")\n", + "agents" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
claimIdcustomerIdclosedmonthsOpen
01140False8
12310True11
23353True4
34498False9
45106False6
...............
995996370True5
996997377True1
997998377False10
998999258False7
9991000207True5
\n", + "

1000 rows × 4 columns

\n", + "
" + ], + "text/plain": [ + " claimId customerId closed monthsOpen\n", + "0 1 140 False 8\n", + "1 2 310 True 11\n", + "2 3 353 True 4\n", + "3 4 498 False 9\n", + "4 5 106 False 6\n", + ".. ... ... ... ...\n", + "995 996 370 True 5\n", + "996 997 377 True 1\n", + "997 998 377 False 10\n", + "998 999 258 False 7\n", + "999 1000 207 True 5\n", + "\n", + "[1000 rows x 4 columns]" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "claims = pd.read_csv(\"./src/main/resources/DataFiles/claims.csv\")\n", + "claims" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
customerIdfirstNamelastNameageareaagentIdagentRatingprimaryLanguagedependentshomePolicyautoPolicyrentersPolicytotalMonthlyPremiumyearsOfServicevehiclesInsured
01AlexineSpinella66area-5182ArabicNaNTrueFalseFalse$498380
12AlricSkoggins38area-325Hindi[{\"firstName\":\"Lucien\",\"lastName\":\"Trobe\"},{\"f...FalseTrueFalse$80244
23DoraDugmore22area-4121Hindi[{\"firstName\":\"Cassi\",\"lastName\":\"Valens-Smith...TrueFalseFalse$48600
34FrederigoMenchenton20area-541HindiNaNFalseTrueTrue$54405
45ChariotDrogan48area-493Arabic[{\"firstName\":\"Herc\",\"lastName\":\"Sterndale\"},{...FalseTrueFalse$35195
................................................
495496BrinaCasterou42area-1192Arabic[{\"firstName\":\"Sydney\",\"lastName\":\"Murr\"},{\"fi...FalseFalseFalse$000
496497GavanFargher94area-3204ArabicNaNTrueFalseFalse$323470
497498OfellaWinkless63area-5172ArabicNaNFalseTrueTrue$613252
498499CammyLeffek23area-521English[{\"firstName\":\"Phyllis\",\"lastName\":\"Stokell\"},...TrueTrueFalse$67453
499500LorinCharles31area-4153Arabic[{\"firstName\":\"Piggy\",\"lastName\":\"Hymor\"},{\"fi...TrueFalseFalse$65820
\n", + "

500 rows × 15 columns

\n", + "
" + ], + "text/plain": [ + " customerId firstName lastName age area agentId agentRating \\\n", + "0 1 Alexine Spinella 66 area-5 18 2 \n", + "1 2 Alric Skoggins 38 area-3 2 5 \n", + "2 3 Dora Dugmore 22 area-4 12 1 \n", + "3 4 Frederigo Menchenton 20 area-5 4 1 \n", + "4 5 Chariot Drogan 48 area-4 9 3 \n", + ".. ... ... ... ... ... ... ... \n", + "495 496 Brina Casterou 42 area-1 19 2 \n", + "496 497 Gavan Fargher 94 area-3 20 4 \n", + "497 498 Ofella Winkless 63 area-5 17 2 \n", + "498 499 Cammy Leffek 23 area-5 2 1 \n", + "499 500 Lorin Charles 31 area-4 15 3 \n", + "\n", + " primaryLanguage dependents \\\n", + "0 Arabic NaN \n", + "1 Hindi [{\"firstName\":\"Lucien\",\"lastName\":\"Trobe\"},{\"f... \n", + "2 Hindi [{\"firstName\":\"Cassi\",\"lastName\":\"Valens-Smith... \n", + "3 Hindi NaN \n", + "4 Arabic [{\"firstName\":\"Herc\",\"lastName\":\"Sterndale\"},{... \n", + ".. ... ... \n", + "495 Arabic [{\"firstName\":\"Sydney\",\"lastName\":\"Murr\"},{\"fi... \n", + "496 Arabic NaN \n", + "497 Arabic NaN \n", + "498 English [{\"firstName\":\"Phyllis\",\"lastName\":\"Stokell\"},... \n", + "499 Arabic [{\"firstName\":\"Piggy\",\"lastName\":\"Hymor\"},{\"fi... \n", + "\n", + " homePolicy autoPolicy rentersPolicy totalMonthlyPremium \\\n", + "0 True False False $498 \n", + "1 False True False $802 \n", + "2 True False False $486 \n", + "3 False True True $544 \n", + "4 False True False $351 \n", + ".. ... ... ... ... \n", + "495 False False False $0 \n", + "496 True False False $323 \n", + "497 False True True $613 \n", + "498 True True False $674 \n", + "499 True False False $658 \n", + "\n", + " yearsOfService vehiclesInsured \n", + "0 38 0 \n", + "1 4 4 \n", + "2 0 0 \n", + "3 0 5 \n", + "4 9 5 \n", + ".. ... ... \n", + "495 0 0 \n", + "496 47 0 \n", + "497 25 2 \n", + "498 5 3 \n", + "499 2 0 \n", + "\n", + "[500 rows x 15 columns]" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "customers = pd.read_csv(\"./src/main/resources/DataFiles/customers.csv\")\n", + "customers" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
vendorIdareavendorRatinginScope
01area-54True
12area-15True
23area-55True
34area-54False
45area-34False
...............
9596area-33True
9697area-55True
9798area-55True
9899area-34False
99100area-51True
\n", + "

100 rows × 4 columns

\n", + "
" + ], + "text/plain": [ + " vendorId area vendorRating inScope\n", + "0 1 area-5 4 True\n", + "1 2 area-1 5 True\n", + "2 3 area-5 5 True\n", + "3 4 area-5 4 False\n", + "4 5 area-3 4 False\n", + ".. ... ... ... ...\n", + "95 96 area-3 3 True\n", + "96 97 area-5 5 True\n", + "97 98 area-5 5 True\n", + "98 99 area-3 4 False\n", + "99 100 area-5 1 True\n", + "\n", + "[100 rows x 4 columns]" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vendors = pd.read_csv(\"./src/main/resources/DataFiles/vendors.csv\")\n", + "vendors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Looks nice! Now let's try to do one of the problems we were given using these Pandas dataframes\n", + "It'll go much smoother, just watch!
\n", + "Let's code *getAgentCountInArea*. How many agents reside in area-4?" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "247\n" + ] + } + ], + "source": [ + "print(len(agents[agents.area == 'area-4']))\n", + "# prints 247 (the correct answer!!)\n", + "# this only took one line of code" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.2" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/ExtraFeatures/Visualizations.html b/ExtraFeatures/Visualizations.html new file mode 100644 index 0000000..f3e1274 --- /dev/null +++ b/ExtraFeatures/Visualizations.html @@ -0,0 +1,444 @@ + + + + + + + + + + + + + +State Farm Visualization + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+

Step 1: Importing our data

+

We’ll starting by importing our data

+
agents = read.csv("agents.csv")
+claims = read.csv("claims.csv")
+customers = read.csv("customers.csv")
+vendors = read.csv("vendors.csv")
+
+
+

Step 2: Visualizing Some Data

+

Let’s start with a histogram of agents’ ratings

+
hist(customers$agentRating,
+     col = "dodgerblue",
+     main = "Agent's Ratings",
+     xlab = "Rating from 1-5",
+     ylab = "Frequency")
+

+

Next, we can see how the customer’s age corresponds to their years of service (Orange/Blue represent if they have home policy insurance)

+
plot(age ~ yearsOfService, data = customers,
+     cex = 1,
+     col= ifelse(homePolicy, "dodgerblue", "orange"),
+     pch = 20,
+     xlab = "Years of Service",
+     ylab = "Age",
+     main = "Customer Age vs Years of Service")
+

+

These are just some of the powerful things that R can provide with this data!

+
+ + + + +
+ + + + + + + + + + + + + + + diff --git a/feedback.txt b/feedback.txt index f9d5935..8a84e8c 100644 --- a/feedback.txt +++ b/feedback.txt @@ -2,7 +2,7 @@ Your team (name of each individual participating): Nishant Balepur, Sanjana Sark How many JUnits were you able to get to pass? All ten test cases Document and describe any enhancements included to help the judges properly grade your submission. - Step 1: - Step 2: + Step 1: Data visualization in R + Step 2: Pandas Dataframe Organization in Jupyter Notebook Feedback for the coding competition? Things you would like to see in future events? 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 index 745636c..58e2627 100644 --- a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties +++ b/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Sat Oct 10 21:33:31 CDT 2020 +#Sat Oct 10 23:53:25 CDT 2020 m2e.projectLocation=C\:\\Users\\nishu\\OneDrive\\Desktop\\Code\\2020-StateFarm-CodingCompetitionProblem m2e.projectName=coding-competition groupId=sf.codingcompetition2020