Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

test #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>coding-competition</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
15 changes: 15 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
5 changes: 3 additions & 2 deletions feedback.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Your team (name of each individual participating):
How many JUnits were you able to get to pass?
Your team (name of each individual participating): 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:
Step 2:


Feedback for the coding competition? Things you would like to see in future events?
It was really cool!
143 changes: 133 additions & 10 deletions src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -29,8 +32,106 @@ public class CodingCompCsvUtil {
* @param classType -- Class of entries being read in.
* @return -- List of entries being returned.
*/
@SuppressWarnings("unchecked")
public <T> List<T> readCsvFile(String filePath, Class<T> 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<Agent> agents = new ArrayList<Agent>();
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<T>)agents;
}
else if(classType==Claim.class) {
List<Claim> claims = new ArrayList<Claim>();
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<T>)claims;
}
else if(classType==Customer.class) {
List<Customer> customers = new ArrayList<Customer>();
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<T>)customers;
}
else {
List<Vendor> vendors = new ArrayList<Vendor>();
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<T>)vendors;
}

}
catch(IOException e) {
System.out.println(e);

}
return null;
}


Expand All @@ -41,7 +142,12 @@ public <T> List<T> readCsvFile(String filePath, Class<T> classType) {
* @return -- The number of agents in a given area
*/
public int getAgentCountInArea(String filePath,String area) {

List<Agent> agents = readCsvFile(filePath,Agent.class);
int numInArea = 0;
for(Agent a : agents) {
if(a.getArea().equals(area)) numInArea++;
}
return numInArea;
}


Expand All @@ -53,7 +159,12 @@ public int getAgentCountInArea(String filePath,String area) {
* @return -- The number of agents in a given area
*/
public List<Agent> getAgentsInAreaThatSpeakLanguage(String filePath, String area, String language) {

List<Agent> agents = readCsvFile(filePath,Agent.class);
List<Agent> agentsInParam = new ArrayList<Agent>();
for(Agent a : agents) {
if(a.getArea().equals(area) & a.getLanguage().equals(language)) agentsInParam.add(a);
}
return agentsInParam;
}


Expand All @@ -66,7 +177,19 @@ public List<Agent> getAgentsInAreaThatSpeakLanguage(String filePath, String area
* @return -- The number of customers that use a certain agent in a given area.
*/
public short countCustomersFromAreaThatUseAgent(Map<String,String> csvFilePaths, String customerArea, String agentFirstName, String agentLastName) {

List<Agent> agents = readCsvFile(csvFilePaths.get("agentList"),Agent.class);
List<Customer> 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;
}


Expand All @@ -77,7 +200,7 @@ public short countCustomersFromAreaThatUseAgent(Map<String,String> csvFilePaths,
* @return -- List of customers retained for a given number of years, in ascending order of policy cost.
*/
public List<Customer> getCustomersRetainedForYearsByPlcyCostAsc(String customerFilePath, short yearsOfService) {

return null;
}


Expand All @@ -88,7 +211,7 @@ public List<Customer> getCustomersRetainedForYearsByPlcyCostAsc(String customerF
* @return -- List of customers who’ve made an inquiry for a policy but have not signed up.
*/
public List<Customer> getLeadsForInsurance(String filePath) {

return null;
}


Expand All @@ -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<Vendor> getVendorsWithGivenRatingThatAreInScope(String filePath, String area, boolean inScope, int vendorRating) {

return null;
}


Expand All @@ -117,7 +240,7 @@ public List<Vendor> getVendorsWithGivenRatingThatAreInScope(String filePath, Str
* @return -- List of customers filtered by age, number of vehicles insured and the number of dependents.
*/
public List<Customer> getUndisclosedDrivers(String filePath, int vehiclesInsured, int dependents) {

return null;
}


Expand All @@ -130,7 +253,7 @@ public List<Customer> getUndisclosedDrivers(String filePath, int vehiclesInsured
* @return -- Agent ID of agent with the given rank.
*/
public int getAgentIdGivenRank(String filePath, int agentRank) {

return 0;
}


Expand All @@ -141,7 +264,7 @@ public int getAgentIdGivenRank(String filePath, int agentRank) {
* @return -- List of customers who’ve filed a claim within the last <numberOfMonths>.
*/
public List<Customer> getCustomersWithClaims(Map<String,String> csvFilePaths, short monthsOpen) {

return null;
}

}
32 changes: 32 additions & 0 deletions src/main/java/sf/codingcompetition2020/structures/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


}
27 changes: 27 additions & 0 deletions src/main/java/sf/codingcompetition2020/structures/Claim.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}



}
Loading