Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.
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
49 changes: 49 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?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/J2SE-1.5">
<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="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
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>codingcompetition2019</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>
5 changes: 5 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
2 changes: 2 additions & 0 deletions .settings/org.eclipse.jdt.apt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false
9 changes: 9 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -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
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
13 changes: 9 additions & 4 deletions feedback.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
Your team (name of each individual participating):
How many JUnits were you able to get to pass?
Your team (name of each individual participating): Champ Foronda, Joshua Holguin
How many JUnits were you able to get to pass? 6

Document and describe any enhancements included to help the judges properly grade your submission.
Step 1:

No nice to have features were added.

Step 1:
Step 2:


Feedback for the coding competition? Things you would like to see in future events?
Feedback for the coding competition? Things you would like to see in future events?
Competition was super fun, would love do this again! The problem and the methods in itself were not difficult, it was just figuring out how all the pieces work together
and how to implement in Java.
140 changes: 128 additions & 12 deletions src/main/java/codingcompetition2019/CodingCompCSVUtil.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,148 @@
package codingcompetition2019;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.io.FileReader;
import java.io.BufferedReader;

public class CodingCompCSVUtil {
public List<List<String>> readCSVFileByCountry(String fileName, String countryName) throws IOException {
public class CodingCompCSVUtil
{

private BufferedReader csvReader;
public List<List<String>> readCSVFileByCountry(String fileName, String countryName) throws IOException
{
// TODO implement this method
return null;
if(fileName.equals(""))
{
throw new IOException();
}

List<List<String>> csvData = new ArrayList<List<String>>();
csvReader = new BufferedReader(new FileReader(fileName));

String rowString = "";
while((rowString = csvReader.readLine()) != null)
{
String[] splitRowData = rowString.split(",");
if(splitRowData[0].equals(countryName))
{
List<String> rowEntryData = new ArrayList<String>();
for(int dataIndex = 0; dataIndex < splitRowData.length; dataIndex++)
{
rowEntryData.add(splitRowData[dataIndex]);
}
csvData.add(rowEntryData);
}
}

return csvData;
}

public List<List<String>> readCSVFileWithHeaders(String fileName) throws IOException {
// TODO implement this method
return null;
BufferedReader fileReader = null;
List<List<String>> CSVWithHeaders = new ArrayList<List<String>>();
List<String> rowData = new ArrayList<String>();
String[] rowHelper = new String[4];
try
{
String line = "";

// Creating file reader
fileReader = new BufferedReader(new FileReader(fileName));

while((line = fileReader.readLine()) != null)
{
rowHelper = line.split(",");
for(int dataIndex = 0; dataIndex < rowHelper.length; dataIndex++)
{
rowData.add(rowHelper[dataIndex]);
}
CSVWithHeaders.add(rowData);
}

fileReader.close();
return CSVWithHeaders;
}

catch(Exception e)
{
throw new IOException();
}
}

public List<List<String>> readCSVFileWithoutHeaders(String fileName) throws IOException {
public List<List<String>> readCSVFileWithoutHeaders(String fileName) throws IOException
{
// TODO implement this method
return null;
if(fileName.equals(""))
{
throw new IOException();
}

csvReader = new BufferedReader(new FileReader(fileName));
List<List<String>> csvData = new ArrayList<List<String>>();
csvReader.readLine();

String rowString = "";
while((rowString = csvReader.readLine()) != null)
{
String[] splitRowData = rowString.split(",");
List<String> rowEntryData = new ArrayList<String>();
for(int dataIndex = 0; dataIndex < splitRowData.length; dataIndex++)
{
rowEntryData.add(splitRowData[dataIndex]);
}

csvData.add(rowEntryData);
}

return csvData;
}

public DisasterDescription getMostImpactfulYear(List<List<String>> records) {
// TODO implement this method
return null;
public DisasterDescription getMostImpactfulYear(List<List<String>> records)
{
int maxImpact = 0;
int currentImpact = 0;
String maxYear = "";
for(List<String> list:records)
{
currentImpact = Integer.valueOf(list.get(3));
if (currentImpact > maxImpact)
{
maxImpact = currentImpact;
maxYear = list.get(2);
}
}
DisasterDescription dd = new DisasterDescription();
dd.setYear(maxYear);
System.out.println(maxYear);
return dd;
}

public DisasterDescription getMostImpactfulYearByCategory(String category, List<List<String>> records) {
public DisasterDescription getMostImpactfulYearByCategory(String category, List<List<String>> records)
{
// TODO implement this method
return null;
DisasterDescription description = new DisasterDescription();
description.setCategory(category);
int maxImpact = 0;
int currentImpact = 0;
String maxYear = "";

for(List<String> record : records)
{
currentImpact = Integer.valueOf(record.get(3));
if(record.get(0).equals(category))
{
if(currentImpact > maxImpact)
{
maxImpact = currentImpact;
maxYear = record.get(2);
}
}
}

description.setYear(maxYear);
return description;
}

public DisasterDescription getMostImpactfulDisasterByYear(String year, List<List<String>> records) {
Expand Down
44 changes: 43 additions & 1 deletion src/main/java/codingcompetition2019/DisasterDescription.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
package codingcompetition2019;

public class DisasterDescription {
public class DisasterDescription
{
// TODO finish this class
private String year;
private String category;
private int incidentNumber;

public DisasterDescription()
{
this.year = "";
this.category = "";
this.incidentNumber = 0;
}

public String getYear()
{
return this.year;
}

public String getCategory()
{
return this.category;
}

public int getReportedIncidentsNum()
{
return this.incidentNumber;
}

public void setYear(String inYear)
{
this.year = inYear;
}

public void setCategory(String inCategory)
{
this.category = inCategory;
}

public void setReportedIncidentsNum(int inIncidentNum)
{
this.incidentNumber = inIncidentNum;
}

}
5 changes: 5 additions & 0 deletions target/classes/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Manifest-Version: 1.0
Built-By: cforonda
Build-Jdk: 13
Created-By: Maven Integration for Eclipse

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Generated by Maven Integration for Eclipse
#Sat Oct 05 20:42:09 MST 2019
m2e.projectLocation=/Users/cforonda/Documents/workspace/coding_competition/state_farm_2019/2019-StateFarm-CodingCompetitionProblem
m2e.projectName=codingcompetition2019
groupId=codingcompetition2019
artifactId=codingcompetition2019
version=0.0.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>codingcompetition2019</groupId>
<artifactId>codingcompetition2019</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>codingcompetition2019</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Binary file not shown.
Binary file not shown.
Loading