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
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/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="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
8 changes: 8 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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.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
4 changes: 2 additions & 2 deletions feedback.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Your team (name of each individual participating):
How many JUnits were you able to get to pass?
Your team (name of each individual participating):Jaewon Jeung
How many JUnits were you able to get to pass? 8

Document and describe any enhancements included to help the judges properly grade your submission.
Step 1:
Expand Down
61 changes: 47 additions & 14 deletions src/main/java/codingcompetition2019/CodingCompCSVUtil.java
Original file line number Diff line number Diff line change
@@ -1,42 +1,75 @@
package codingcompetition2019;

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

public class CodingCompCSVUtil {
public List<List<String>> readCSVFileByCountry(String fileName, String countryName) throws IOException {
// TODO implement this method
return null;
String tempStr = "";
BufferedReader br = new BufferedReader(new FileReader(fileName));
ArrayList<ArrayList<String>> row = new ArrayList<ArrayList<String>>();
ArrayList<ArrayList<String>> selected = new ArrayList<ArrayList<String>>();

while((tempStr = br.readLine()) != null) {
String [] tempCol = tempStr.split(",");
ArrayList<String> col = new ArrayList<String>(Arrays.asList(tempCol));
row.add(col);
}

for (int i = 0; i < row.size(); i++) {
if (row.get(i).get(0).contains(countryName)) {
selected.add(row.get(i));
}
}
List<List<String>> result = (List)selected;
return result;
}

public List<List<String>> readCSVFileWithHeaders(String fileName) throws IOException {
// TODO implement this method
return null;
String tempStr = "";
BufferedReader br = new BufferedReader(new FileReader(fileName));
ArrayList<ArrayList<String>> row = new ArrayList<ArrayList<String>>();
ArrayList<ArrayList<String>> selected = new ArrayList<ArrayList<String>>();

while((tempStr = br.readLine()) != null) {
String [] tempCol = tempStr.split(",");
ArrayList<String> col = new ArrayList<String>(Arrays.asList(tempCol));
row.add(col);
}

List<List<String>> result = (List)row;
return result;
}

public List<List<String>> readCSVFileWithoutHeaders(String fileName) throws IOException {
// TODO implement this method
return null;
ArrayList<ArrayList<String>> row = new ArrayList<ArrayList<String>>((ArrayList)readCSVFileWithHeaders("src/main/resources/natural-disasters-by-type.csv"));
row.remove(0);
List<List<String>> result = (List)row;
return result;
}

public DisasterDescription getMostImpactfulYear(List<List<String>> records) {
// TODO implement this method
return null;
DisasterDescription highest = new DisasterDescription(records);
return highest;
}

public DisasterDescription getMostImpactfulYearByCategory(String category, List<List<String>> records) {
// TODO implement this method
return null;
DisasterDescription high = new DisasterDescription(category, records);
return high;
}

public DisasterDescription getMostImpactfulDisasterByYear(String year, List<List<String>> records) {
// TODO implement this method
return null;
DisasterDescription byYear = new DisasterDescription(0, year, records);
return byYear;
}

public DisasterDescription getTotalReportedIncidentsByCategory(String category, List<List<String>> records) {
// TODO implement this method
return null;
DisasterDescription byCat = new DisasterDescription(0, 0, category, records);
return byCat;
}

/**
Expand Down
112 changes: 110 additions & 2 deletions src/main/java/codingcompetition2019/DisasterDescription.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,113 @@
package codingcompetition2019;

import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class DisasterDescription {
// TODO finish this class
}
int highest = 0;
String highestYr = "";
String category = "";

public DisasterDescription(List<List<String>> records) {
this.highest = 0;
this.highestYr = "";
for (int i = 0; i < records.size(); i++) {
if ((Integer.parseInt(records.get(i).get(3))) > highest) {
highest = Integer.parseInt(records.get(i).get(3));
highestYr = records.get(i).get(2);
}
}
}

public DisasterDescription(String cat, List<List<String>> records) {
this.highest = 0;
this.highestYr = "";

List<List<String>> newRecords = records;

for (int i = 0; i < newRecords.size(); i++){
if(newRecords.get(i).get(0).contains(cat)) {
continue;
}
else {
newRecords.remove(i);
i--;
}
}

for (int i = 0; i < newRecords.size(); i++) {
if ((Integer.parseInt(newRecords.get(i).get(3))) > highest) {
highest = Integer.parseInt(newRecords.get(i).get(3));
highestYr = newRecords.get(i).get(2);
}
}
}

public DisasterDescription(int no, String year, List<List<String>> records) {
this.highest = 0;
this.highestYr = "";

List<List<String>> newRecords = records;

for (int i = 0; i < newRecords.size(); i++){
if(newRecords.get(i).get(0).contains("All natural disasters")){
newRecords.remove(i);
i--;
}

else if(newRecords.get(i).get(2).contains(year)) {
continue;
}
else {
newRecords.remove(i);
i--;
}
}

for (int i = 0; i < newRecords.size(); i++) {
if ((Integer.parseInt(newRecords.get(i).get(3))) > highest) {
highest = Integer.parseInt(newRecords.get(i).get(3));
category = newRecords.get(i).get(0);
}
}
}

public DisasterDescription(int no, int nono, String cat, List<List<String>> records) {
this.highest = 0;
this.highestYr = "";

List<List<String>> newRecords = records;

for (int i = 0; i < newRecords.size(); i++){
if(newRecords.get(i).get(0).contains("All natural disasters")){
newRecords.remove(i);
i--;
}

else if(newRecords.get(i).get(0).contains(cat)){
continue;
}
else {
newRecords.remove(i);
i--;
}
}

for (int i = 0; i < newRecords.size(); i++) {
highest += Integer.parseInt(newRecords.get(i).get(3));
}
}

public String getYear() {
return highestYr;
}

public String getCategory() {
return category;
}

public int getReportedIncidentsNum() {
return highest;
}
}
Binary file not shown.
Binary file not shown.
Loading