From de65647f0d1b2698cfd0f8104e77830dd3850c55 Mon Sep 17 00:00:00 2001 From: Evan Mitchell Date: Sat, 10 Oct 2020 20:42:50 -0700 Subject: [PATCH 1/3] Pass all unit tests --- .classpath | 49 ++++ .project | 34 +++ .settings/org.eclipse.jdt.apt.core.prefs | 2 + .settings/org.eclipse.jdt.core.prefs | 9 + .settings/org.eclipse.m2e.core.prefs | 4 + .../CodingCompCsvUtil.java | 211 +++++++++++++++--- .../structures/Agent.java | 28 ++- .../structures/Claim.java | 21 +- .../structures/Customer.java | 65 +++++- .../structures/Dependent.java | 4 + .../structures/Vendor.java | 21 +- .../CodingCompCsvUtilTest.java | 45 ++-- target/classes/META-INF/MANIFEST.MF | 5 - .../coding-competition/pom.properties | 7 - .../coding-competition/pom.xml | 32 --- .../CodingCompCsvUtil$1.class | Bin 0 -> 1336 bytes .../CodingCompCsvUtil$2.class | Bin 0 -> 1335 bytes .../CodingCompCsvUtil.class | Bin 3251 -> 11111 bytes .../structures/Agent.class | Bin 428 -> 1058 bytes .../structures/Claim.class | Bin 397 -> 841 bytes .../structures/Customer.class | Bin 806 -> 2962 bytes .../structures/Dependent.class | Bin 384 -> 488 bytes .../structures/Vendor.class | Bin 419 -> 901 bytes .../CodingCompCsvUtilTest.class | Bin 3972 -> 5230 bytes 24 files changed, 434 insertions(+), 103 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 delete mode 100644 target/classes/META-INF/MANIFEST.MF delete mode 100644 target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties delete mode 100644 target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.xml create mode 100644 target/classes/sf/codingcompetition2020/CodingCompCsvUtil$1.class create mode 100644 target/classes/sf/codingcompetition2020/CodingCompCsvUtil$2.class 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..f150776 --- /dev/null +++ b/.project @@ -0,0 +1,34 @@ + + + coding-competition + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + + + 1602378236374 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + 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..aa93303 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -1,11 +1,18 @@ package sf.codingcompetition2020; +import java.io.BufferedReader; import java.io.FileReader; +import java.io.IOException; import java.io.Reader; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -20,31 +27,79 @@ import sf.codingcompetition2020.structures.Claim; import sf.codingcompetition2020.structures.Customer; import sf.codingcompetition2020.structures.Vendor; +import sf.codingcompetition2020.structures.Dependent; public class CodingCompCsvUtil { - - /* #1 + + /* #1 * readCsvFile() -- Read in a CSV File and return a list of entries in that file. * @param filePath -- Path to file being read in. * @param classType -- Class of entries being read in. * @return -- List of entries being returned. */ public List readCsvFile(String filePath, Class classType) { + List result = new ArrayList(); + try { + BufferedReader csvReader = new BufferedReader(new FileReader(filePath)); + String row = csvReader.readLine(); + while ((row = csvReader.readLine()) != null) { + String[] data = row.split(",(?![^\\[]*\\])"); + if (classType == Agent.class) { + T agent = (T) new Agent(Integer.parseInt(data[0]), data[1], data[2], data[3], data[4]); + result.add(agent); + } else if (classType == Claim.class) { + T claim = (T) new Claim(Integer.parseInt(data[0]), Integer.parseInt(data[1]), Boolean.parseBoolean(data[2]), + Integer.parseInt(data[3])); + result.add(claim); + } else if (classType == Customer.class) { + List dependentsList = new ArrayList(); + if (data[8].length() > 0) { + String[] dependents = data[8].substring(1, data[8].length() - 1).split(",(?![^{]*})"); + for (String dependent : dependents) { + String[] name = dependent.substring(1, dependent.length() - 1).split(","); + String firstName = name[0].split("\"\"")[2]; + String lastName = name[1].split("\"\"")[2]; + dependentsList.add(new Dependent(firstName, lastName)); + } + } + T customer = (T) new Customer(Integer.parseInt(data[0]), data[1], data[2], Integer.parseInt(data[3]), data[4], + Integer.parseInt(data[5]), Short.parseShort(data[6]), data[7], dependentsList, + Boolean.parseBoolean(data[9]), Boolean.parseBoolean(data[10]), Boolean.parseBoolean(data[11]), data[12], + Short.parseShort(data[13]), Integer.parseInt(data[14])); + result.add(customer); + } else if (classType == Vendor.class) { + T vendor = (T) new Vendor(Integer.parseInt(data[0]), data[1], Integer.parseInt(data[2]), + Boolean.parseBoolean(data[3])); + result.add(vendor); + } else { + return null; + } + } + csvReader.close(); + } catch (IOException e) { + return null; + } + return result; } - /* #2 * getAgentCountInArea() -- Return the number of agents in a given area. * @param filePath -- Path to file being read in. * @param area -- The area from which the agents should be counted. * @return -- The number of agents in a given area */ - public int getAgentCountInArea(String filePath,String area) { - + public int getAgentCountInArea(String filePath, String area) { + List agents = readCsvFile(filePath, Agent.class); + int result = 0; + for (Agent agent : agents) { + if (agent.getArea().equals(area)) { + result++; + } + } + return result; } - /* #3 * getAgentsInAreaThatSpeakLanguage() -- Return a list of agents from a given area, that speak a certain language. * @param filePath -- Path to file being read in. @@ -53,10 +108,16 @@ public int getAgentCountInArea(String filePath,String area) { * @return -- The number of agents in a given area */ public List getAgentsInAreaThatSpeakLanguage(String filePath, String area, String language) { - + List agents = readCsvFile(filePath, Agent.class); + List qualifiedAgents = new ArrayList(); + for (Agent agent : agents) { + if (agent.getArea().equals(area) && agent.getLanguage().equals(language)) { + qualifiedAgents.add(agent); + } + } + return qualifiedAgents; } - - + /* #4 * countCustomersFromAreaThatUseAgent() -- Return the number of individuals from an area that use a certain agent. * @param filePath -- Path to file being read in. @@ -65,11 +126,25 @@ public List getAgentsInAreaThatSpeakLanguage(String filePath, String area * @param agentLastName -- Last name of agent. * @return -- The number of customers that use a certain agent in a given area. */ - public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, String customerArea, String agentFirstName, String agentLastName) { - + public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, String customerArea, + String agentFirstName, String agentLastName) { + List customers = readCsvFile(csvFilePaths.get("customerList"), Customer.class); + List agents = readCsvFile(csvFilePaths.get("agentList"), Agent.class); + short result = 0; + for (Customer customer : customers) { + if (customer.getArea().equals(customerArea)) { + int agentId = customer.getAgentId(); + for (Agent agent : agents) { + if (agent.getAgentId() == agentId && agent.getFirstName().equals(agentFirstName) + && agent.getLastName().equals(agentLastName)) { + result++; + } + } + } + } + return result; } - /* #5 * getCustomersRetainedForYearsByPlcyCostAsc() -- Return a list of customers retained for a given number of years, in ascending order of their policy cost. * @param filePath -- Path to file being read in. @@ -77,10 +152,22 @@ public short countCustomersFromAreaThatUseAgent(Map csvFilePaths, * @return -- List of customers retained for a given number of years, in ascending order of policy cost. */ public List getCustomersRetainedForYearsByPlcyCostAsc(String customerFilePath, short yearsOfService) { - + List customers = readCsvFile(customerFilePath, Customer.class); + List qualifiedCustomers = new ArrayList(); + for (Customer customer : customers) { + if (customer.getYearsOfService() == yearsOfService) { + qualifiedCustomers.add(customer); + } + } + Comparator compareByPremium = new Comparator() { + public int compare(Customer c1, Customer c2) { + return c1.getTotalMonthlyPremium().compareTo(c2.getTotalMonthlyPremium()); + } + }; + qualifiedCustomers.sort(compareByPremium); + return qualifiedCustomers; } - /* #6 * getLeadsForInsurance() -- Return a list of individuals who’ve made an inquiry for a policy but have not signed up. * *HINT* -- Look for customers that currently have no policies with the insurance company. @@ -88,12 +175,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) { - + List customers = readCsvFile(filePath, Customer.class); + List qualifiedCustomers = new ArrayList(); + for (Customer customer : customers) { + if (!customer.getAutoPolicy() && !customer.getHomePolicy() && !customer.getRentersPolicy()) { + qualifiedCustomers.add(customer); + } + } + return qualifiedCustomers; } - /* #7 - * getVendorsWithGivenRatingThatAreInScope() -- Return a list of vendors within an area and include options to narrow it down by: + * getVendorsWithGivenRatingThatAreInScope() -- Return a list of vendors within an area and include options to narrow it down by: a. Vendor rating b. Whether that vendor is in scope of the insurance (if inScope == false, return all vendors in OR out of scope, if inScope == true, return ONLY vendors in scope) * @param filePath -- Path to file being read in. @@ -102,11 +195,18 @@ b. Whether that vendor is in scope of the insurance (if inScope == false, return * @param vendorRating -- The rating of the vendor. * @return -- List of vendors within a given area, filtered by scope and vendor rating. */ - public List getVendorsWithGivenRatingThatAreInScope(String filePath, String area, boolean inScope, int vendorRating) { - + public List getVendorsWithGivenRatingThatAreInScope(String filePath, String area, boolean inScope, + int vendorRating) { + List vendors = readCsvFile(filePath, Vendor.class); + List qualifiedVendors = new ArrayList(); + for (Vendor vendor : vendors) { + if (vendor.getArea().equals(area) && vendor.getVendorRating() >= vendorRating && ((inScope && vendor.getInScope()) || !inScope)) { + qualifiedVendors.add(vendor); + } + } + return qualifiedVendors; } - /* #8 * getUndisclosedDrivers() -- Return a list of customers between the age of 40 and 50 years (inclusive), who have: a. More than X cars @@ -117,31 +217,80 @@ public List getVendorsWithGivenRatingThatAreInScope(String filePath, Str * @return -- List of customers filtered by age, number of vehicles insured and the number of dependents. */ public List getUndisclosedDrivers(String filePath, int vehiclesInsured, int dependents) { - - } - + List customers = readCsvFile(filePath, Customer.class); + List qualifiedCustomers = new ArrayList(); + for (Customer customer : customers) { + if (customer.getVehiclesInsured() > vehiclesInsured && customer.getAge() >= 40 && customer.getAge() <= 50 + && customer.getDependents().size() <= dependents) { + qualifiedCustomers.add(customer); + } + } + return qualifiedCustomers; + } /* #9 - * getAgentIdGivenRank() -- Return the agent with the given rank based on average customer satisfaction rating. - * *HINT* -- Rating is calculated by taking all the agent rating by customers (1-5 scale) and dividing by the total number + * getAgentIdGivenRank() -- Return the agent with the given rank based on average customer satisfaction rating. + * *HINT* -- Rating is calculated by taking all the agent rating by customers (1-5 scale) and dividing by the total number * of reviews for the agent. * @param filePath -- Path to file being read in. * @param agentRank -- The rank of the agent being requested. * @return -- Agent ID of agent with the given rank. */ public int getAgentIdGivenRank(String filePath, int agentRank) { - - } + List customers = readCsvFile(filePath, Customer.class); + Map> ratings = new HashMap>(); + for (Customer customer : customers) { + List agentRatings = ratings.get(customer.getAgentId()); + if (agentRatings == null) { + agentRatings = new ArrayList(); + } + agentRatings.add(customer.getAgentRating()); + ratings.put(customer.getAgentId(), agentRatings); + } + + Iterator>> it = ratings.entrySet().iterator(); + List> averageRatings = new ArrayList>(); + while (it.hasNext()) { + Entry> entry = it.next(); + int sum = 0; + for (Short rating : entry.getValue()) { + sum += rating; + } + float averageRating = sum / (float) entry.getValue().size(); + averageRatings.add(Arrays.asList((float) entry.getKey(), averageRating)); + } + + Comparator> compareByAverageRating = new Comparator>() { + public int compare(List l1, List l2) { + return l2.get(1).compareTo(l1.get(1)); + } + }; + + averageRatings.sort(compareByAverageRating); + return Math.round(averageRatings.get(agentRank - 1).get(0)); + } + - /* #10 - * getCustomersWithClaims() -- Return a list of customers who’ve filed a claim within the last (inclusive). + * getCustomersWithClaims() -- Return a list of customers who’ve filed a claim within the last (inclusive). * @param filePath -- Path to file being read in. * @param monthsOpen -- Number of months a policy has been open. * @return -- List of customers who’ve filed a claim within the last . */ public List getCustomersWithClaims(Map csvFilePaths, short monthsOpen) { - - } + List claims = readCsvFile(csvFilePaths.get("claimList"), Claim.class); + List customers = readCsvFile(csvFilePaths.get("customerList"), Customer.class); + Set qualifiedCustomers = new HashSet(); + for (Claim claim : claims) { + if (claim.getMonthsOpen() <= monthsOpen) { + for (Customer customer : customers) { + if (claim.getCustomerId() == customer.getCustomerId()) { + qualifiedCustomers.add(customer); + } + } + } + } + return new ArrayList(qualifiedCustomers); + } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Agent.java b/src/main/java/sf/codingcompetition2020/structures/Agent.java index e2e6f93..65a4634 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Agent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Agent.java @@ -1,11 +1,35 @@ package sf.codingcompetition2020.structures; public class Agent { - + private int agentId; private String area; private String language; private String firstName; private String lastName; - + + public Agent(int agentId, String area, String language, String firstName, String lastName) { + this.agentId = agentId; + this.area = area; + this.language = language; + this.firstName = firstName; + this.lastName = lastName; + } + + public int getAgentId() { + return agentId; + } + public String getArea() { + return area; + } + public String getLanguage() { + return language; + } + public String getFirstName() { + return firstName; + } + public String getLastName() { + return lastName; + } + } diff --git a/src/main/java/sf/codingcompetition2020/structures/Claim.java b/src/main/java/sf/codingcompetition2020/structures/Claim.java index 581140a..35cc43d 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Claim.java +++ b/src/main/java/sf/codingcompetition2020/structures/Claim.java @@ -5,5 +5,24 @@ public class Claim { private int customerId; private boolean closed; private int monthsOpen; - + + public Claim(int claimId, int customerId, boolean closed, int monthsOpen) { + this.claimId = claimId; + this.customerId = customerId; + this.closed = closed; + this.monthsOpen = monthsOpen; + } + + public int getClaimId() { + return claimId; + } + public int getCustomerId() { + return customerId; + } + public boolean getClosed() { + return closed; + } + public int getMonthsOpen() { + return monthsOpen; + } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Customer.java b/src/main/java/sf/codingcompetition2020/structures/Customer.java index f151906..17984d8 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Customer.java +++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java @@ -7,7 +7,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -public class Customer { +public class Customer{ private int customerId; private String firstName; private String lastName; @@ -24,4 +24,67 @@ public class Customer { private short yearsOfService; private Integer vehiclesInsured; + public Customer(int customerId, String firstName, String lastName, int age, String area, int agentId, short agentRating, String primaryLanguage, List dependents, boolean homePolicy, boolean autoPolicy, boolean rentersPolicy, String totalMonthlyPremium, short yearsOfService, Integer vehiclesInsured) { + this.customerId = customerId; + this.firstName = firstName; + this.lastName = lastName; + this.age = age; + this.area = area; + this.agentId = agentId; + this.agentRating = agentRating; + this.primaryLanguage = primaryLanguage; + this.dependents = dependents; + this.homePolicy = homePolicy; + this.autoPolicy = autoPolicy; + this.rentersPolicy = rentersPolicy; + this.totalMonthlyPremium = totalMonthlyPremium; + this.yearsOfService = yearsOfService; + this.vehiclesInsured = vehiclesInsured; + } + + public int getCustomerId() { + return customerId; + } + public String getFirstName() { + return firstName; + } + public String getLastName() { + return lastName; + } + public int getAge() { + return age; + } + public String getArea() { + return area; + } + public int getAgentId() { + return agentId; + } + public short getAgentRating() { + return agentRating; + } + public String getPrimaryLanguage() { + return primaryLanguage; + } + public List getDependents() { + return dependents; + } + public boolean getHomePolicy() { + return homePolicy; + } + public boolean getAutoPolicy() { + return autoPolicy; + } + public boolean getRentersPolicy() { + return rentersPolicy; + } + public String getTotalMonthlyPremium() { + return totalMonthlyPremium; + } + public short getYearsOfService() { + return yearsOfService; + } + public Integer getVehiclesInsured() { + return vehiclesInsured; + } } diff --git a/src/main/java/sf/codingcompetition2020/structures/Dependent.java b/src/main/java/sf/codingcompetition2020/structures/Dependent.java index d4deb1a..d4bbb1d 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Dependent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Dependent.java @@ -4,4 +4,8 @@ public class Dependent { private String firstName; private String lastName; + public Dependent(String firstName, String lastName) { + this.firstName = firstName; + 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..f47470e 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Vendor.java +++ b/src/main/java/sf/codingcompetition2020/structures/Vendor.java @@ -5,5 +5,24 @@ public class Vendor { private String area; private int vendorRating; private boolean inScope; - + + public Vendor(int vendorId, String area, int vendorRating, boolean inScope) { + this.vendorId = vendorId; + this.area = area; + this.vendorRating = vendorRating; + this.inScope = inScope; + } + + public int getVendorId() { + return vendorId; + } + public String getArea() { + return area; + } + public int getVendorRating() { + return vendorRating; + } + public boolean getInScope() { + return inScope; + } } diff --git a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java index c29959f..ed6cfbc 100644 --- a/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java +++ b/src/test/java/sf/codingcompetition2020/CodingCompCsvUtilTest.java @@ -13,7 +13,7 @@ import sf.codingcompetition2020.structures.Customer; public class CodingCompCsvUtilTest{ - + private final String agentFilePath = "src/main/resources/DataFiles/agents.csv"; private final String claimFilePath = "src/main/resources/DataFiles/claims.csv"; private final String customerFilePath = "src/main/resources/DataFiles/customers.csv"; @@ -21,10 +21,10 @@ public class CodingCompCsvUtilTest{ private final String agentList = "agentList"; private final String claimList = "claimList"; private final String customerList = "customerList"; - - + + CodingCompCsvUtil codingCompCsVUtil = new CodingCompCsvUtil(); - + //#1 @Test public void test1() { @@ -32,14 +32,14 @@ public void test1() { assertEquals(424, ((Claim)codingCompCsVUtil.readCsvFile(claimFilePath, Claim.class).get(423)).getClaimId()); assertEquals("Lorin", ((Customer)codingCompCsVUtil.readCsvFile(customerFilePath, Customer.class).get(499)).getFirstName()); } - + //#2 @Test public void getAgentCountInArea() { assertEquals(247,codingCompCsVUtil.getAgentCountInArea(agentFilePath, "area-4")); assertEquals(55,codingCompCsVUtil.getAgentCountInArea(agentFilePath, "area-2")); } - + //#3 @Test public void getAgentsInAreaThatSpeakLanguage() { @@ -47,29 +47,29 @@ public void getAgentsInAreaThatSpeakLanguage() { 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<>(); - + 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()); @@ -78,13 +78,13 @@ public void getCustomersRetainedForYearsByPlcyCostAsc() { assertEquals("Tesoe",customerList.get(5).getLastName()); assertEquals("$888",customerList.get(14).getTotalMonthlyPremium()); } - + //#6 @Test public void getLeadsForInsurance() { assertEquals(82, codingCompCsVUtil.getLeadsForInsurance(customerFilePath).size()); } - + //#7 @Test public void getVendorsWithGivenRatingThatAreInScope() { @@ -92,33 +92,32 @@ public void getVendorsWithGivenRatingThatAreInScope() { assertEquals(2, codingCompCsVUtil.getVendorsWithGivenRatingThatAreInScope(vendorFilePath, "area-2", true, 2).size()); assertEquals(12, codingCompCsVUtil.getVendorsWithGivenRatingThatAreInScope(vendorFilePath, "area-3", false, 3).size()); } - + //#8 @Test - public void getCustomersRetainedForYearsByPlcyCostAsc2() { + public void getCustomersRetainedForYearsByPlcyCostAsc2() { assertEquals(15,codingCompCsVUtil.getUndisclosedDrivers(customerFilePath,2,2).size()); assertEquals(14,codingCompCsVUtil.getUndisclosedDrivers(customerFilePath,3,3).size()); } - + //#9 @Test - public void getAgentIdGivenRank() { + public void getAgentIdGivenRank() { 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); - + assertEquals(81,codingCompCsVUtil.getCustomersWithClaims(csvFilePaths, Short.valueOf("1")).size()); assertEquals(312,codingCompCsVUtil.getCustomersWithClaims(csvFilePaths, Short.valueOf("6")).size()); } } - diff --git a/target/classes/META-INF/MANIFEST.MF b/target/classes/META-INF/MANIFEST.MF deleted file mode 100644 index e2a1a34..0000000 --- a/target/classes/META-INF/MANIFEST.MF +++ /dev/null @@ -1,5 +0,0 @@ -Manifest-Version: 1.0 -Built-By: yc1d -Build-Jdk: 1.8.0_201 -Created-By: Maven Integration for Eclipse - diff --git a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties b/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties deleted file mode 100644 index fe569e3..0000000 --- a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.properties +++ /dev/null @@ -1,7 +0,0 @@ -#Generated by Maven Integration for Eclipse -#Thu Oct 08 09:27:33 MST 2020 -version=1.0.0-SNAPSHOT -groupId=sf.codingcompetition2020 -m2e.projectName=coding-competition -m2e.projectLocation=/Users/yc1d/Development/coding-competition/problem/online-competition -artifactId=coding-competition diff --git a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.xml b/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.xml deleted file mode 100644 index 21d55bf..0000000 --- a/target/classes/META-INF/maven/sf.codingcompetition2020/coding-competition/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - 4.0.0 - coding-competition - 1.0.0-SNAPSHOT - jar - sf.codingcompetition2020 - - coding-competition - Coding Competition - - - - - - - junit - junit - 4.12 - test - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-csv - 2.11.2 - - - - diff --git a/target/classes/sf/codingcompetition2020/CodingCompCsvUtil$1.class b/target/classes/sf/codingcompetition2020/CodingCompCsvUtil$1.class new file mode 100644 index 0000000000000000000000000000000000000000..94324849b3382f24962c1b994198ce2eeb7798df GIT binary patch literal 1336 zcmb7ET~8B16g|^c*49NTLd9>?BK?AGk+%{OY$U-HB^HT3nPC~rlI;$enUe5#jE}zf zASON-pZ!tBJKHr@Kmu)M_s;E|bMHOpPJjOT_8mY2iw;r@HT~Z6Y=0@)sLax?_ptieTTJQM)#(@0-37+H3W-kv*ZB z|Ic()0wqi8sq zIo!jvgZuyJKlshX13YBNCVg*8hRM=Ngz_3g%5R*>=qc3_qbYxZVRjgDFnG$zY_gXwrqwcaG4?F-L#c_( zbzyepjsuUOa{gQ4(w!w9$|T#LiP5iw;WW%Ut5UrcTF zB5vGJJJ5zobJwCss8-0e78=vUV4Bt?uzcQLA^N*W)5^kfdxfk;r05IeD%CG=D_?Q- zGwo8iM$Zw70X|@yo^EXCa2*r0qp?6CL3mEl7SpXB;YN+t5$=AX{V>MI7-M=6mta`T zM<~X)E@sF|)%ab*9KAD`M;%Yd KvJKmI=<^$Pe_?O{ literal 0 HcmV?d00001 diff --git a/target/classes/sf/codingcompetition2020/CodingCompCsvUtil$2.class b/target/classes/sf/codingcompetition2020/CodingCompCsvUtil$2.class new file mode 100644 index 0000000000000000000000000000000000000000..eeb69198e9648a15db6f6661c962a286f2cf22e8 GIT binary patch literal 1335 zcmb7DT~8B16g{)8tSt+zd{o2_P^xs>N=rq3C}~0(F`E=k1bH9Yu?#M|WOqv9fAYl# zG5TP5_D31-Y*$zc571`XJ9p;Zd(OFc{`~#*8^9`Fn=lxv;ip>H?@6!U^$(APl1lns zqu!|3+L5ht-0`XLG2{e9&B}0BX;en}YJY>Fa8d6sNB=cn8VR_H8^dz4 zWQ_ST3){)k5L7M9qQH>d_6I>%Y)akl!ll_>(QFyEE~iN#Iv?y9S2XUru~*@2(JbWN zcwN^I>2+-hweR;#5c~4=UxI}-ykwZBW^MF^r<~qfc`UpS-1|%{k}_lZ<Pljm{$iE`x>^Ho|WsOX{zGIUjw(aF*j XpskgdL=E-GyNVZhMV1ywQ>M>9y^cqO literal 0 HcmV?d00001 diff --git a/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class b/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class index 00daba9d49249e6950fa6b4b75732ac294bb504b..a0ca2166ca281ea213e95d53dc8a12a0b84a274a 100644 GIT binary patch literal 11111 zcmb_i3wRvWbv{Sh-Pv7@ELpY;3$`%=8$B&sfUs9WMt(?MkRMpGh-?h3rIoy}+7Jln!lSXtH0k$ou2Hjc!sIAW9Ak$F%_j_ z(LNa17MF?7uI$L$*O^VjttMB`nnW~{X{ypaIk;5c5zk~XOQ178kc?(?Y0R;;xhw3t zM|;`SGJ~0$ySkcMrcAGU4VuF=M;WIUZcV47!?Jpi$|zvaJf?Z-YCKiHI@jMHOUL@Q zz_nP~pc8?ZeNFt-{Xsf`P7;VuW-6b?x~lFVmD2(lu@FmJBQU+by-8nRWYVcr!Q>Yl zB~VOrD=manlr0qfbUIUUZRM&{w_kGc_8rw1@2CpW5~?)lj0vRB!%eE9Y9?=HC=mxk z&X~@;?Jkh5MGUHCsyb@?Gud>mSAvwOZyksw0o_tsW>7uT?0nQC$!u&OmNscQHNdT* zXgU)^-%&7%1gVD35{%Af>ZpuNwdweJs=ABl99n763Z_~4s7t_23KJ+-813tuWRyj< zs%-|HJ3}16==fleR#B@#=S{$2bt;vJMUy72rZr5a!oljBw5$bw)wUot(>lSTjmfBt zM7Bk$x(!;7oSaEW*5oqT)L<+vv^d|S3#bFqkccG*vb&Tt0O}>Q(WFhZ83~uk?L;_{ zpWr=~nwD`}klvbc*X*diuF6kcOkC?Hh)h96g+U)J(RbqXYiQ$m~= zWIAy=CnDRl{-jJAl1;+fn@DA12BmG4giu8`t=rQZ8iy%%mVy^^@1F@_U z^EIhlG8;*@Vjr4uazav=K5f!0DiOK;j7guR&w(oOY%Cqkrog3n_Fkr3h*)?TThQ zhhotyI#Au^U>DQ+X*O;bSFD|5YLBIB4sWnp?*D13nUT!)QUdj)Nnepb6~W)UYse$p z%MuAzygwf6Q@0@)6}`endq>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FpNm>;M1& diff --git a/target/classes/sf/codingcompetition2020/structures/Agent.class b/target/classes/sf/codingcompetition2020/structures/Agent.class index 26bf31f236fb6fb54997543cc9d682faad0ab137..2903afd58d56353fe8a8759412c5dd1021e2d050 100644 GIT binary patch literal 1058 zcmbVK+iuf95IyTS*P13xL))a3rd(rlap^0l5<;pJ$tn*;dEYp0aFy7|Uh^e<1`i-% zA@RTm@KK1FO-m)$4+vS>IXgRN_RLxT`u*c4fETdqFa+%M-1XyG7|s27`5{oD3ghVL z@aWJ@Rg(ECOM=vWJr5#PhbhpxkRPSHkkQ%udY zQ2Unx4d!K3F3>y=lT@9`C1FZm!P=`Z3e~ZIHyYpU@P8S5LaN@xv!I0vIu!WtR^Z7+<1(`-2nl6P{tAoX1@_T^$ClaTk9 zNmIQKQ-LSmKf6ozwB~`*PP3OJkld_uN*mf6**C`*Sfc{(ud5dAPOgnz9bS3cI*YT! z4^Bc>-O?95=SRW;&0L{hq6&k}AY`x=I+77Ok_|eN2^4F@uyBjkb=rNRdS(rs?`S)_ zIl9i%96je*jxDEe=Gbxi)f|Jby2Bk>?^1t|p(b@{QlEADHqk~O9qeNRdvtod>PfZx zw4?4?o6v~W85*%Z);{EiqJE56V-fgc5Pj=7331$ykcLpVr9g|+7zvk(8;DCKBujxFKsog0I7_;fKPr38nIFUj zi3o`UKY$;FnAzkIMLuxx%+Abv^WON+-(SB0yu`CMEP+w^If(O_%I0yN-bt;r%Cn2} zi}Rq=MHTC+kY#Y0L@I5=7TCRwzC=M1W%J-_dMjfs(2ltq&ICj#;KWs_^HdgGXvIlh zO72`!C(Sc`Q(oQ4j5=>rru17vpM~LdIGPC9m-$ROXkf=h7rO$Dv(cmjf%`6+XmPgZ zqP@%>xVVQ7*B-iX&=S}gt4w~V(y1&yMbktQZk)$aGKmVs?^V&(H>wnPKK^gtuSxn` zYI6fNMY71}7MIqncFf4qElrSLo_N1z+4-1PMJ(Sb*5(+x7ko`TAr}q$B{nQJN}0tr zO(c^hl0}M5n(V@*?-sqjnt8zUe`4D|SfJ-0F3|Un78v*gdx7D1gWadEXYd``;SggN z+r-i*mVL@R>c1jxo;tuGMb21>Fd1vHOvY+hsmCWLE`cLFTB!*r@_f_(f!;StEF#B> wq-U0}a5k}AB5+&_?r(zkYQc}q-S`gcn+KcVVJ-M+?dIVo*sBGf7;~rp0GRWAsQ>@~ delta 120 zcmX@f*2~Ow>ff$?3=9m03}O?xT1A;PG{YDfSe)}yQn?tI8Tfe^xEXjRUW=bx#pvY0 z$iN8V0!dz=4t*fa2&7rHwlnZ;1TvTy1b`$PSdf`P5Xc581u9?=Vh{$>j0_?`l8HeS E00zSjdH?_b diff --git a/target/classes/sf/codingcompetition2020/structures/Customer.class b/target/classes/sf/codingcompetition2020/structures/Customer.class index 844ea29474f5bc9dd328dee078d97b0567ad1de8..7a8a2415b4e5638c544efb2f2454c84a5e21e9f0 100644 GIT binary patch literal 2962 zcmcIlT~pge6g>iiv5|p5OzS31LkIzj4+BX`6Fw43LgLl|iV01q+ZkbmQO33yNoIzB z(BIMLKD0B{blQjhfc&UV&#n*4hMbj5)dZo8* z`UEg(SwsJ^Yd1{yw8YXa2}&PW$5!)z2#y3GRFgB|rgFbWv2vNBZoa5hQfL8ix$zyvlNGZkm0TP+>5TxCzJObj2gI*v4*v_;ME1CL6mxVY3kV( z=UzltFOB{H*V`XX|1d*4st4d2H{QnH0CCIR_%o1=E+F69Xzcjtl%1AawbpGRgG}^w zX2dIt5o)WG&wD>Qgox>N2nkC|0ZU8yN=xxdOX*5W;Yv%{N=wl)+o1G^n1|ApK7}hS zWh*U3D=j4}Ed@(EK_xiv_NhaSv-4M-da)L>{kU;0K=g znpu7c`{w>Lu6P5agaEJ5+$AbTgcqCX?c!K9H=?SI<*A?+d@Vf|4ur2tjh)055 z3QsVdmY(3cS9*eNU3!A=jPwNKg7b=aB$(+reVx3A*@l=+BL^?|OYTvi6?(QIQXd&yrpb=F5dQ<68s&u&u6XN_Py`NldLO~>`?OU?LUmS zUsQs3mEeUqxTFMsuLM7egEy7nH%j6b<9FUxg5N4X*>b${YbAJ(??XFbPvVu|D8Usu HMnC=sGKMH3 delta 122 zcmbOvzKo6Q)W2Q(7#J7~8Pqp&?O+sT*3b-NWMFa5Pf6usU}jL@VUS^voxFuPaq=P7 zWgd(Sj37RclmqI~2hxl{npJB%gZxGygNZ>ANV0(ixfqmyY#xXL24w~nAditj6|71P E0FMX|P5=M^ diff --git a/target/classes/sf/codingcompetition2020/structures/Dependent.class b/target/classes/sf/codingcompetition2020/structures/Dependent.class index 3ee505f7dda4d5aad7c64d98dd9748ea80a0698b..df7b2d15eba33c05197c24ead13da269b83fa1ba 100644 GIT binary patch delta 215 zcmZo*e!(no>ff$?3=9m03=-@NOpFY=6EEscwDk>E*YL?oEKAhSNz6;v4=yRn%uBb% z6wwT0WMFa5Pf6usU}oUqVc=lkWn^I1& zRLQ`=ueF_lTT6Q@1D}@8RtABMKp`duAs{Klzyc)Mfg}e5ClK;6a4`r2MHC>~7(^IE afjpoAAhUr+gIGYbfw~zP#DF{|25|tTuOP_) delta 102 zcmaFC+`!Cr>ff$?3=9m048jw+8bp~jG{YDfSe)}yQn?tI8F+XYI2br5-d%2`&%g+T p3=FJV+Znhw0vSvUyg-r-EXd5j2W0a=6fp2J2mpDE41!=)LICNc4J`lw diff --git a/target/classes/sf/codingcompetition2020/structures/Vendor.class b/target/classes/sf/codingcompetition2020/structures/Vendor.class index fdbca9b6e0183e880547b8ff174552c31967ec4f..42d9a1ce549ed77f856f1863686023f3d887168f 100644 GIT binary patch literal 901 zcma)3O>fgc5Pj=7b>l3wP181YDdn?GtO}Qk8x;~lLb4QrL{JXBZJZ@+mD-iF>6stI z0VELrQk43@WoLGF-pqS%fBpXP6Tnj(cyJiP$%iP(hAJH;+4+UkN~%COV%cdYa2g)R*Zn%RRUZt7qa;L}QVTqPK%HnP`UPOZyxT8CcBVid+hYM)$h2 zr*m5HoPigu?}Vm1gQwD7l3hpwo-!<*s8s0}46Sy26C9s*`ZWAiHk3XpSmoeYW2m${ z{Tdk7IjUGP*#?J)Ws_}j)QZ|RhmShLN>`=w&GdXA^Y>yfrp1kJmWXj*YN>LaNOr;HUujLh(;_R{*%YiLZR2Ddddb%cglEUn|47 zUhH^c?8SYOS)uQA;TZjtIYzyWq}@hRPO(az9JlDaO}9_B9|*$lSP6G#XoQC|G{fB) zHp2~fhSpb$4d@K)oEq)$$ff$?3=9m04B`{HW{NUvXofK|usG+Zq;fGZGYIf7@G$UB{2f1e3!{q% zBLgFd3nck~I`n}wBamj*+Rnhg5y)U-5CoEJU_oXEAt0LvqJTk|K?KNSWDo_b5(5Ak CeGbq7 diff --git a/target/test-classes/sf/codingcompetition2020/CodingCompCsvUtilTest.class b/target/test-classes/sf/codingcompetition2020/CodingCompCsvUtilTest.class index 765ac60fa2a1b12f484db96055457db1849af952..4dbfcea3245603ca43f0e6fc956462c2272ad6da 100644 GIT binary patch literal 5230 zcmb7Hd2kz78UL*>ZRCw&Zxkm@p*hH5ORW_ng@&6z?Iz7o$_?cxL%EOPoHASkv@qeAVfej0v};EWss51O``&xs z_xq0D_nsdA?<0=_Xv2SEsFKiXpUC8jBZfJeD;6en$8e0I*}kEDL#Er6c2nAIPablN z{D5vdG1N$CIH^r)nY?C>X7&%C)N_u6h1#fYIz2{SKcG2d64c&sPrqYPeJ3|{7fsvI zOlMHbmvk8mB&@fsT&AEIX2#O(V#&(sc4mj>XhM^nah2MwIeU_ab9v1u1Qui{|L?H7 z-#^@tE7?x5pj+YjMG{h1G#(uBRU{^LbEFtiph{@Iq5|)Le|&-KORr%&G8Ri%;G*-U zOC%_PF;B8oLZg=yFZ_cd{1UG3z4~M^+;v+F({Q#)sBUfTy(Kg@SAGoCT1u zN{Q#(TeL0YMMTn_*KE79#gmkn@r=2VzOozbLhjzB^f73ERCWYZWM_gQ!or;P8|GTM&jU0TC#znn`IONMePz+1~zTa z-oTjV^iSy8crTl5iLFD%M6i9M42#9N(;Uqk_Lu;{+?Xgy*d0yAydWyTnp<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+Unh6AB* z#bFUq9Hz^@mF|cr65_EzQiP-ySEeUNUGAcFdU(|3ILY+}1VqXm>(l0Q)@EjvGjQ&L0EjUHrG(DPtZnUA7MuKl229P9M{WwCS6fqhm z4(DjkY1%1ymNAa^Nn$udJ6mv;#)9`b`WFmO`wU|*FtL!h@EjNapjpqN*asYHLW|YW zCPUHgkk^IIu_P{~f5vDcnwZ+a^wVFEOX8+KbK9S394+n!ZIBL?!ch!089Y`uI2&qk zGyS;``Xfzf4f=&$pxp^UJ0FU+unV-iA!t`a(e8($O;O;5YX_2e;5stCfzN)$B7^X5 z!6Ivt3zbBu!;D`SJu06wI From 6c5eb413e3a1dbab2ce259438b2fb3c4ce2c2f3f Mon Sep 17 00:00:00 2001 From: Evan Mitchell Date: Sat, 10 Oct 2020 21:43:20 -0700 Subject: [PATCH 2/3] Create graph --- feedback.txt | 11 +- .../CodingCompCsvUtil.java | 44 +++++ .../sf/codingcompetition2020/GraphPanel.java | 153 ++++++++++++++++++ .../java/sf/codingcompetition2020/Gui.java | 36 +++++ .../structures/Customer.java | 2 +- .../structures/Dependent.java | 7 + .../CodingCompCsvUtil.class | Bin 11111 -> 12103 bytes .../sf/codingcompetition2020/GraphPanel.class | Bin 0 -> 5590 bytes .../sf/codingcompetition2020/Gui.class | Bin 0 -> 2134 bytes .../structures/Dependent.class | Bin 488 -> 662 bytes 10 files changed, 246 insertions(+), 7 deletions(-) create mode 100644 src/main/java/sf/codingcompetition2020/GraphPanel.java create mode 100644 src/main/java/sf/codingcompetition2020/Gui.java create mode 100644 target/classes/sf/codingcompetition2020/GraphPanel.class create mode 100644 target/classes/sf/codingcompetition2020/Gui.class diff --git a/feedback.txt b/feedback.txt index b931d50..6066d30 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): Evan Mitchell and Li Ying (Merissa) Tan +How many JUnits were you able to get to pass? 10/10 Document and describe any enhancements included to help the judges properly grade your submission. - Step 1: - Step 2: - - + 1. getPossibleVendorsForClaim() + + 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 aa93303..dbe9bf3 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -293,4 +293,48 @@ public List getCustomersWithClaims(Map csvFilePaths, sh return new ArrayList(qualifiedCustomers); } + /* + * getPossibleVendorsForClaim() -- Return a list of customers who’ve filed a claim within the last (inclusive). + * @param filePath -- Path to file being read in. + * @param claimId -- ID of an open claim. + * @return -- List of vendors within the area of the claim. + */ + public List getPossibleVendorsForClaim(Map csvFilePaths, int claimId) { + List claims = readCsvFile(csvFilePaths.get("claimList"), Claim.class); + List customers = readCsvFile(csvFilePaths.get("customerList"), Customer.class); + List vendors = readCsvFile(csvFilePaths.get("vendorList"), Vendor.class); + List qualifiedVendors = new ArrayList(); + for (Claim claim : claims) { + if (claim.getClaimId() == claimId && !claim.getClosed()) { + for (Customer customer : customers) { + if (claim.getCustomerId() == customer.getCustomerId()) { + for (Vendor vendor : vendors) { + if (vendor.getArea() == customer.getArea()) { + qualifiedVendors.add(vendor); + } + } + } + } + } + } + return qualifiedVendors; + } + + /* + * countClaimsOpenForMonths() -- Return the number of claims open for a given number of months. + * @param filePath -- Path to file being read in. + * @param monthsOpen -- Number of months a policy has been open. + * @return -- Number claims open for . + */ + public int countClaimsOpenForMonths(String filePath, int monthsOpen) { + List claims = readCsvFile(filePath, Claim.class); + int result = 0; + for (Claim claim : claims) { + if (claim.getMonthsOpen() == monthsOpen && !claim.getClosed()) { + result++; + } + } + return result; + } + } diff --git a/src/main/java/sf/codingcompetition2020/GraphPanel.java b/src/main/java/sf/codingcompetition2020/GraphPanel.java new file mode 100644 index 0000000..3070458 --- /dev/null +++ b/src/main/java/sf/codingcompetition2020/GraphPanel.java @@ -0,0 +1,153 @@ +/** + * https://stackoverflow.com/questions/8693342/drawing-a-simple-line-graph-in-java + */ + +package sf.codingcompetition2020; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.RenderingHints; +import java.awt.Stroke; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +public class GraphPanel extends JPanel { + private int width = 800; + private int heigth = 400; + private int padding = 25; + private int labelPadding = 25; + private Color lineColor = new Color(44, 102, 230, 180); + private Color pointColor = new Color(100, 100, 100, 180); + private Color gridColor = new Color(200, 200, 200, 200); + private static final Stroke GRAPH_STROKE = new BasicStroke(2f); + private int pointWidth = 4; + private int numberYDivisions = 10; + private List scores; + + public GraphPanel(List scores) { + this.scores = scores; + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2 = (Graphics2D) g; + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + double xScale = ((double) getWidth() - (2 * padding) - labelPadding) / (scores.size() - 1); + double yScale = ((double) getHeight() - 2 * padding - labelPadding) / (getMaxScore()); + + List graphPoints = new ArrayList(); + for (int i = 0; i < scores.size(); i++) { + int x1 = (int) (i * xScale + padding + labelPadding); + int y1 = (int) ((getMaxScore() - scores.get(i)) * yScale + padding); + graphPoints.add(new Point(x1, y1)); + } + + // draw white background + g2.setColor(Color.WHITE); + g2.fillRect(padding + labelPadding, padding, getWidth() - (2 * padding) - labelPadding, getHeight() - 2 * padding - labelPadding); + g2.setColor(Color.BLACK); + + // create hatch marks and grid lines for y axis. + for (int i = 0; i < numberYDivisions + 1; i++) { + int x0 = padding + labelPadding; + int x1 = pointWidth + padding + labelPadding; + int y0 = getHeight() - ((i * (getHeight() - padding * 2 - labelPadding)) / numberYDivisions + padding + labelPadding); + int y1 = y0; + if (scores.size() > 0) { + g2.setColor(gridColor); + g2.drawLine(padding + labelPadding + 1 + pointWidth, y0, getWidth() - padding, y1); + g2.setColor(Color.BLACK); + String yLabel = ((int) ((getMaxScore() * ((i * 1.0) / numberYDivisions)) * 100)) / 100.0 + ""; + FontMetrics metrics = g2.getFontMetrics(); + int labelWidth = metrics.stringWidth(yLabel); + g2.drawString(yLabel, x0 - labelWidth - 5, y0 + (metrics.getHeight() / 2) - 3); + } + g2.drawLine(x0, y0, x1, y1); + } + + // and for x axis + for (int i = 0; i < scores.size(); i++) { + if (scores.size() > 1) { + int x0 = i * (getWidth() - padding * 2 - labelPadding) / (scores.size() - 1) + padding + labelPadding; + int x1 = x0; + int y0 = getHeight() - padding - labelPadding; + int y1 = y0 - pointWidth; + if ((i % ((int) ((scores.size() / 20.0)) + 1)) == 0) { + g2.setColor(gridColor); + g2.drawLine(x0, getHeight() - padding - labelPadding - 1 - pointWidth, x1, padding); + g2.setColor(Color.BLACK); + String xLabel = i + 1 + ""; + FontMetrics metrics = g2.getFontMetrics(); + int labelWidth = metrics.stringWidth(xLabel); + g2.drawString(xLabel, x0 - labelWidth / 2, y0 + metrics.getHeight() + 3); + } + g2.drawLine(x0, y0, x1, y1); + } + } + + // create x and y axes + g2.drawLine(padding + labelPadding, getHeight() - padding - labelPadding, padding + labelPadding, padding); + g2.drawLine(padding + labelPadding, getHeight() - padding - labelPadding, getWidth() - padding, getHeight() - padding - labelPadding); + + Stroke oldStroke = g2.getStroke(); + g2.setColor(lineColor); + g2.setStroke(GRAPH_STROKE); + for (int i = 0; i < graphPoints.size() - 1; i++) { + int x1 = graphPoints.get(i).x; + int y1 = graphPoints.get(i).y; + int x2 = graphPoints.get(i + 1).x; + int y2 = graphPoints.get(i + 1).y; + g2.drawLine(x1, y1, x2, y2); + } + + g2.setStroke(oldStroke); + g2.setColor(pointColor); + for (int i = 0; i < graphPoints.size(); i++) { + int x = graphPoints.get(i).x - pointWidth / 2; + int y = graphPoints.get(i).y - pointWidth / 2; + int ovalW = pointWidth; + int ovalH = pointWidth; + g2.fillOval(x, y, ovalW, ovalH); + } + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(width, heigth); + } + private double getMinScore() { + double minScore = Double.MAX_VALUE; + for (Double score : scores) { + minScore = Math.min(minScore, score); + } + return minScore; + } + + private double getMaxScore() { + double maxScore = Double.MIN_VALUE; + for (Double score : scores) { + maxScore = Math.max(maxScore, score); + } + return maxScore; + } + + public void setScores(List scores) { + this.scores = scores; + invalidate(); + this.repaint(); + } + + public List getScores() { + return scores; + } +} diff --git a/src/main/java/sf/codingcompetition2020/Gui.java b/src/main/java/sf/codingcompetition2020/Gui.java new file mode 100644 index 0000000..6b22797 --- /dev/null +++ b/src/main/java/sf/codingcompetition2020/Gui.java @@ -0,0 +1,36 @@ +package sf.codingcompetition2020; + +import java.util.List; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JLabel; +import java.awt.Dimension; +import java.awt.BorderLayout; +import java.util.ArrayList; + +public class Gui extends JPanel { + public Gui() { + setLayout(new BorderLayout()); + JLabel title = new JLabel("Claims Open for N Months"); + title.setHorizontalAlignment(JLabel.CENTER); + add(title, BorderLayout.NORTH); + CodingCompCsvUtil util = new CodingCompCsvUtil(); + List claimCounts = new ArrayList(); + String claimsPath = "src/main/resources/DataFiles/claims.csv"; + for (int i = 1; i <= 12; i++) { + claimCounts.add((double) util.countClaimsOpenForMonths(claimsPath, i)); + } + GraphPanel graphPanel = new GraphPanel(claimCounts); + graphPanel.setPreferredSize(new Dimension(800, 600)); + add(graphPanel, BorderLayout.CENTER); + } + + public static void main(String[] args) { + JFrame frame = new JFrame("Claims Open for N Months"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new Gui()); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff --git a/src/main/java/sf/codingcompetition2020/structures/Customer.java b/src/main/java/sf/codingcompetition2020/structures/Customer.java index 17984d8..4ce0a0b 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Customer.java +++ b/src/main/java/sf/codingcompetition2020/structures/Customer.java @@ -7,7 +7,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -public class Customer{ +public class Customer { private int customerId; private String firstName; private String lastName; diff --git a/src/main/java/sf/codingcompetition2020/structures/Dependent.java b/src/main/java/sf/codingcompetition2020/structures/Dependent.java index d4bbb1d..16aa45c 100644 --- a/src/main/java/sf/codingcompetition2020/structures/Dependent.java +++ b/src/main/java/sf/codingcompetition2020/structures/Dependent.java @@ -8,4 +8,11 @@ public Dependent(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } + + public String getFirstName(){ + return firstName; + } + public String getLastName(){ + return lastName; + } } diff --git a/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class b/target/classes/sf/codingcompetition2020/CodingCompCsvUtil.class index a0ca2166ca281ea213e95d53dc8a12a0b84a274a..2d50e87e7cbf292cd7c31cfdcd6eb1234dc408f9 100644 GIT binary patch delta 948 zcmYjO-%FEG7=GTlefwQD4f|#V84Q1rKhmas4iOfXH7zeP@*z-u2c`=dwTlU3dqe zf@aJx5Q?=HS)N$j@k)8&KH|O*ik*t8YPh{S)EbI(MtjwUXs^FJ7`{v>C=6T*_6N)Q zV&U$xreIHPW6^(wKv<2{68a0Z(mc0z-I=egxvI56m$ltOcL}zBA*Zu!@X>t-jU&Ki zHWc!WoqBoFK^hVSt0+g+P$$9Mq1!hy+SL*5i=^r5$(~Szzt$9u#4f7Zy89S8Uzg`^ z%icqDi*Cb!Z0^xOV=x1>f-E@szN)PidE&(-Idmt51p_|7;|eD+shAewI{Oy6igX}_ zDS~22U{toGFilMIDQ4N6qBcO4vMEh+ zB;b)98B#o~*kyYXf0%`jb8yO%Y)`>!z!{zMlrXcgqDu;t(0?INOqO194_UDBUWe`6 zR~d4s93HBGLI>feO0-cGy66yw$cu5R#yr*F4IRdN#!FoPMwM~=qI%d_$@fEfZ!Zfla{9{v?Y@5Q2BoIBIeaz=6Vu{)M=`SvE`FLv0Szcpi zTv7u2Woc_%CfSsv0Up;j9q_oMVI%49dXVvrpF54uStp(3UR{%p!$K!urvM7536<0g zFXMV@5kb}QPuO=WC_hxhL{NSj5e_dHDC)W2Q(7#J7~8GG3om>3zfCI?DNPTVcH(Q3WaWHuQ$M()kNGJFD>OpKjC gRZNUsjNL$5ih-HYjA1up4;v@LeIOqQ7=0i#0OH{hvj6}9 diff --git a/target/classes/sf/codingcompetition2020/GraphPanel.class b/target/classes/sf/codingcompetition2020/GraphPanel.class new file mode 100644 index 0000000000000000000000000000000000000000..d7d8ab5aca1e0265423cc9914a7eafc367ef59ed GIT binary patch literal 5590 zcma)A3wRXO75?w+W}lN6us~D<6(Lyyfe5K47zqi4Kp;pk5LC#Log@RB-MG7fMBDnp zrYiFJtkqUqS}oPuibysfR&8t5T3cIfYg?uPh9+=IqN}1a7B-{Zow43NBWWhhShR9s<-&@_c&M*ueJE-~ z+;9p^+7a3n8mLI@CTqoNMHk51ZHALQ0-{O4)nl05^26O13QK_kdL*>nh^$Y4dLw4k zsEEsl``+%j8MfDYtTPm83&l^v;1;vL7R7xqQ zG2W$3{IOhFqQeKjl=mqey0tn(N4~YH(NSbcK2t}rwK_}3BuplP$sUvOIkox!NJvIt zYA!N^eQ9(G`a&v;di!EgBbp?q4U9}RmD6Ttf`~~RR_drngBz;^CTILh^Her?u^P>8 ztPz-&+1+47!$zFhy^2~AI@V$xlWNV1_HA|RHa68YH`TQ^t!osRF_xscM`o`v25Y3` z^*YYR2FAFpuKAo5W5>6(P~xPlyldIM!{|)b_|S-rI?e%uU6e4AIbsDWv)s(tN+^vJ ze|pitGs;bst{~e2n%c_vo0PF4a$q?LpSC~wL5i0&`WNf6$q3zl})tW zjTk{tLCLzBK16YWj=0hsR=2e+6zS)^q@b|`UN6gx4+-p&3A~$Cj0s%UCUp<$xDXdn zH%pe(JyCPn7B5r(GdeyCKTmF2)wFSijLaoEF2!ZUk&&^>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hjUYVBgMtLwv@L;Mx&$q{Z)nKCHX|CFzg8j{3Qh`9LS4wxWXxXvz%mqz^8PiVO#3#*grZYqASUJDiF0Uz^~^ITMitMshk(C&L;`~>xx?RJN&<71po=Ss1(!cG!9o_2a<$hHw5$Cr*n?*VKnaR- z9$?h3+~XAiZ;9K!i2FxxFE8;>q10cclA4Ow32X;CxLd3BTy^j5eI=)T%L%6{4DB_N%kZ?SMq~mq; zJ2mWbda&DBfC1-mNI1**n-ANH*ujd-YMQRXTzwxuV6F8zXW>!&kTrUV<6S(4$64)L z9M9tkuJW*%a(~2X?Z&w{A5XGTd5GK+{Fo~*@tcgNxboqBykqSWw_o8Wa+l~mrucls z@HYIEG(VBNMV-)zUn!o(&yY_PPsY#j3<`*437#cip?HhqjnYOO@3Q0(%{wi5#PlXh z9+BN^$s?X~@CzxAsLrzF5!-2&Jfit3e#y4&akQaFN%j)adP^R0tyEI{M0Y0bcR?q{ zI-cVy-|;lI*e70R{%~w3W*U1GM|Sv$^(6dSo*?2nej`t0I-7;wZ;773^Z1?B*_dNa zu7ILrc%hxSJ(vH=M)3QCq-m=4SztFE$0%-$>W*IDR^lWWw4t3 zQJ~s+0MkmGNAa4Foon6P`D|WC@Yhw6_IH6>M_-wHZ${HpCE-#^x{TfXa$BEmzZ;t7y$NA7jnv zIBNt!9X~X6&_<2k7N}V!m=c2joS90&*g3g-9Z|TRUfsah-Kex#GfP4Gws7PdKeI@R zoLPi$Gw1D5O?c((!e9GI=UaC6+VNq%IV-Gr>9BGVXYhqz$Pr7<)%jR03Z35n0{TiL Aq5uE@ literal 0 HcmV?d00001 diff --git a/target/classes/sf/codingcompetition2020/Gui.class b/target/classes/sf/codingcompetition2020/Gui.class new file mode 100644 index 0000000000000000000000000000000000000000..ec3f509eca284a7c699a2149e1b71060521303df GIT binary patch literal 2134 zcmZ`)ZC4XV7`;Oh0_&;}1W8qlZXl*+rlVo+XOLsRY_T}g~ zJ*R)9=k#;Ggtj@SKcGLPKcnrPO@xT@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W;ADHoV=Pbhn0bWi9s9y%rXfS From e4b786703ba5b15db122d6a3026947091ea459d9 Mon Sep 17 00:00:00 2001 From: Evan Mitchell Date: Sat, 10 Oct 2020 21:56:01 -0700 Subject: [PATCH 3/3] Add second graph --- feedback.txt | 4 +- .../CodingCompCsvUtil.java | 2 +- .../java/sf/codingcompetition2020/Gui.java | 46 ++++++++++++------ .../sf/codingcompetition2020/Gui.class | Bin 2134 -> 2931 bytes 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/feedback.txt b/feedback.txt index 6066d30..4cc81a4 100644 --- a/feedback.txt +++ b/feedback.txt @@ -2,7 +2,9 @@ Your team (name of each individual participating): Evan Mitchell and Li Ying (Me How many JUnits were you able to get to pass? 10/10 Document and describe any enhancements included to help the judges properly grade your submission. - 1. getPossibleVendorsForClaim() + 1. Add function getPossibleVendorsForClaim() + 2. Graph number of claims open for n months (run Gui.java) + 3. Graph agent count in area i (run Gui.java) 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 dbe9bf3..59a2929 100644 --- a/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java +++ b/src/main/java/sf/codingcompetition2020/CodingCompCsvUtil.java @@ -294,7 +294,7 @@ public List getCustomersWithClaims(Map csvFilePaths, sh } /* - * getPossibleVendorsForClaim() -- Return a list of customers who’ve filed a claim within the last (inclusive). + * getPossibleVendorsForClaim() -- Return a list of vendors in the area of a given claim. * @param filePath -- Path to file being read in. * @param claimId -- ID of an open claim. * @return -- List of vendors within the area of the claim. diff --git a/src/main/java/sf/codingcompetition2020/Gui.java b/src/main/java/sf/codingcompetition2020/Gui.java index 6b22797..a0338d5 100644 --- a/src/main/java/sf/codingcompetition2020/Gui.java +++ b/src/main/java/sf/codingcompetition2020/Gui.java @@ -9,28 +9,44 @@ import java.util.ArrayList; public class Gui extends JPanel { - public Gui() { + public Gui(String title, List points) { setLayout(new BorderLayout()); - JLabel title = new JLabel("Claims Open for N Months"); - title.setHorizontalAlignment(JLabel.CENTER); - add(title, BorderLayout.NORTH); + JLabel titleL = new JLabel(title); + titleL.setHorizontalAlignment(JLabel.CENTER); + add(titleL, BorderLayout.NORTH); + GraphPanel graphPanel = new GraphPanel(points); + graphPanel.setPreferredSize(new Dimension(800, 600)); + add(graphPanel, BorderLayout.CENTER); + } + + public static void main(String[] args) { CodingCompCsvUtil util = new CodingCompCsvUtil(); + + String title1 = "Claims Open for n Months"; List claimCounts = new ArrayList(); String claimsPath = "src/main/resources/DataFiles/claims.csv"; for (int i = 1; i <= 12; i++) { claimCounts.add((double) util.countClaimsOpenForMonths(claimsPath, i)); } - GraphPanel graphPanel = new GraphPanel(claimCounts); - graphPanel.setPreferredSize(new Dimension(800, 600)); - add(graphPanel, BorderLayout.CENTER); - } + JFrame frame1 = new JFrame(title1); + frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame1.getContentPane().add(new Gui(title1, claimCounts)); + frame1.pack(); + frame1.setLocationRelativeTo(null); + frame1.setVisible(true); - public static void main(String[] args) { - JFrame frame = new JFrame("Claims Open for N Months"); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.getContentPane().add(new Gui()); - frame.pack(); - frame.setLocationRelativeTo(null); - frame.setVisible(true); + String title2 = "Agent Count in Area i"; + String agentsPath = "src/main/resources/DataFiles/agents.csv"; + List agentCount = new ArrayList(); + for (int i = 1; i <= 5; i++) { + String area = "area-" + i; + agentCount.add((double) util.getAgentCountInArea(agentsPath, area)); + } + JFrame frame2 = new JFrame(title2); + frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame2.getContentPane().add(new Gui(title2, agentCount)); + frame2.pack(); + frame2.setLocationRelativeTo(null); + frame2.setVisible(true); } } diff --git a/target/classes/sf/codingcompetition2020/Gui.class b/target/classes/sf/codingcompetition2020/Gui.class index ec3f509eca284a7c699a2149e1b71060521303df..5e087152f3819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