From 90c91edfa05ab88ed1c48d4effec5fdcabcc1229 Mon Sep 17 00:00:00 2001 From: Matthew So Date: Sat, 5 Oct 2019 22:58:53 -0400 Subject: [PATCH 1/6] Base Submission --- .classpath | 32 + .project | 23 + .settings/org.eclipse.core.resources.prefs | 5 + .settings/org.eclipse.jdt.core.prefs | 15 + .settings/org.eclipse.m2e.core.prefs | 4 + .../CodingCompCSVUtil.java | 200 +- .../DisasterDescription.java | 45 +- target/classes/META-INF/MANIFEST.MF | 5 + .../codingcompetition2019/pom.properties | 7 + .../codingcompetition2019/pom.xml | 26 + .../CodingCompCSVUtil.class | Bin 0 -> 7978 bytes .../DisasterDescription.class | Bin 0 -> 1323 bytes target/classes/natural-disasters-by-type.csv | 829 + target/classes/significant-earthquakes.csv | 143641 +++++++++++++++ .../significant-volcanic-eruptions.csv | 16808 ++ target/classes/test.csv | 11 + target/classes/test1.csv | 12 + .../CodingCompCSVUtilTest.class | Bin 0 -> 4135 bytes 18 files changed, 161652 insertions(+), 11 deletions(-) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs create mode 100644 target/classes/META-INF/MANIFEST.MF create mode 100644 target/classes/META-INF/maven/codingcompetition2019/codingcompetition2019/pom.properties create mode 100644 target/classes/META-INF/maven/codingcompetition2019/codingcompetition2019/pom.xml create mode 100644 target/classes/codingcompetition2019/CodingCompCSVUtil.class create mode 100644 target/classes/codingcompetition2019/DisasterDescription.class create mode 100644 target/classes/natural-disasters-by-type.csv create mode 100644 target/classes/significant-earthquakes.csv create mode 100644 target/classes/significant-volcanic-eruptions.csv create mode 100644 target/classes/test.csv create mode 100644 target/classes/test1.csv create mode 100644 target/test-classes/codingcompetition2019/CodingCompCSVUtilTest.class diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..5e8d853 --- /dev/null +++ b/.classpath @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..b4cd1c3 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + codingcompetition2019 + + + + + + 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.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..839d647 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -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/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b9a1035 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -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 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/codingcompetition2019/CodingCompCSVUtil.java b/src/main/java/codingcompetition2019/CodingCompCSVUtil.java index 74f3074..9039806 100644 --- a/src/main/java/codingcompetition2019/CodingCompCSVUtil.java +++ b/src/main/java/codingcompetition2019/CodingCompCSVUtil.java @@ -2,41 +2,198 @@ import java.io.IOException; import java.util.List; +import java.io.BufferedReader; +import java.io.FileReader; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Optional; public class CodingCompCSVUtil { + /** + * Produces a list containing a list of table entries found in the CSV file referred to by fileName with a country listing of countryName. + * If the CSV cannot be read, an IOException is thrown. + * + * @param fileName the URI linking to the CSV table containing data to process + * @param countryName the name of the country to filter for + * @return a list of lists containing strings parsed exactly based on CSV format + * @throws IOException if table cannot be found + */ + public List> readCSVFileByCountry(String fileName, String countryName) throws IOException { - // TODO implement this method - return null; + String line = ""; + String cvsSplitBy = ","; + List> fullList = new ArrayList>(); + + try (BufferedReader br = new BufferedReader(new FileReader(fileName))) { + + while ((line = br.readLine()) != null) { + + String[] country = line.split(cvsSplitBy); + + if (countryName.equals(country[0])) { + fullList.add(Arrays.asList(country)); + } + + } + } catch (IOException e) { + e.printStackTrace(); + } + + return fullList; } + /** + * Produces a list containing a list of table entries found in the CSV file referred to by fileName, including headers. + * If the CSV cannot be read, an IOException is thrown. + * + * @param fileName the URI linking to the CSV table containing data to process + * @return a list of lists containing strings parsed exactly based on CSV format + * @throws IOException if table cannot be found + */ + public List> readCSVFileWithHeaders(String fileName) throws IOException { // TODO implement this method - return null; + String line = ""; + String cvsSplitBy = ","; + List> fullList = new ArrayList>(); + + try (BufferedReader br = new BufferedReader(new FileReader(fileName))) { + + while ((line = br.readLine()) != null) { + + fullList.add(Arrays.asList(line.split(cvsSplitBy))); + + } + } catch (IOException e) { + e.printStackTrace(); + } + + return fullList; } + /** + * Produces a list containing a list of table entries found in the CSV file referred to by fileName, excluding headers. + * If the CSV cannot be read, an IOException is thrown. + * + * @param fileName the URI linking to the CSV table containing data to process + * @return a list of lists containing strings parsed exactly based on CSV format + * @throws IOException if table cannot be found + */ + public List> readCSVFileWithoutHeaders(String fileName) throws IOException { // TODO implement this method - return null; + String line = ""; + String cvsSplitBy = ","; + List> fullList = new ArrayList>(); + + try (BufferedReader br = new BufferedReader(new FileReader(fileName))) { + + br.readLine(); // Skips first line (contains header) + + while ((line = br.readLine()) != null) { + + fullList.add(Arrays.asList(line.split(cvsSplitBy))); + + } + } catch (IOException e) { + e.printStackTrace(); + } + + return fullList; } public DisasterDescription getMostImpactfulYear(List> records) { // TODO implement this method - return null; + HashMap yearMap = new HashMap(); + String topYear = ""; + int topVal = 0; + for (List currentList: records) { + String year = currentList.get(2); + int incident; + Optional init = atoi(currentList, 3); + if (!init.isPresent()) { + continue; + } + incident = init.get(); + yearMap.put(year, yearMap.getOrDefault(year, 0) + incident); + if (yearMap.get(year) > topVal) { + topYear = year; + topVal = yearMap.get(year); + } + } + DisasterDescription curr = new DisasterDescription("", "", topYear, 0); + return curr; } public DisasterDescription getMostImpactfulYearByCategory(String category, List> records) { // TODO implement this method - return null; + HashMap yearMap = new HashMap(); + String topYear = ""; + int topVal = 0; + int incident; + for (List currentList: records) { + String year = currentList.get(2); + Optional init = atoi(currentList, 3); + if (!init.isPresent()) { + continue; + } + incident = init.get(); + if (category.equals(currentList.get(0))) { + yearMap.put(year, yearMap.getOrDefault(year, 0) + incident); + if (yearMap.get(year) > topVal) { + topYear = year; + topVal = yearMap.get(year); + } + } + } + DisasterDescription curr = new DisasterDescription("", "", topYear, 0); + return curr; + } public DisasterDescription getMostImpactfulDisasterByYear(String year, List> records) { // TODO implement this method - return null; + HashMap disasterMap = new HashMap(); + String topDisaster = ""; + int topVal = 0; + int incident; + for (List currentList: records) { + String currDisaster = currentList.get(0); + Optional init = atoi(currentList, 3); + if (!init.isPresent()) { + continue; + } + incident = init.get(); + if (year.equals(currentList.get(2)) && !currDisaster.equals("All natural disasters")) { //All natural disasters is the sum of all inputs, so excluding the value removes this exception + disasterMap.put(currDisaster, disasterMap.getOrDefault(currDisaster, 0) + incident); + if (disasterMap.get(currDisaster) > topVal) { + topDisaster = currDisaster; + topVal = disasterMap.get(currDisaster); + } + } + } + DisasterDescription curr = new DisasterDescription(topDisaster, "", year, topVal); + return curr; } public DisasterDescription getTotalReportedIncidentsByCategory(String category, List> records) { // TODO implement this method - return null; + int incident = 0; + int currIncident; + for (List currentList: records) { + Optional init = atoi(currentList, 3); + if (!init.isPresent()) { + continue; + } + currIncident = init.get(); + if (category.equals(currentList.get(0))) { + incident += currIncident; + } + } + + DisasterDescription curr = new DisasterDescription(category, "", "", incident); + return curr; } /** @@ -48,11 +205,34 @@ public DisasterDescription getTotalReportedIncidentsByCategory(String category, */ public int countImpactfulYearsWithReportedIncidentsWithinRange(List> records, int min, int max) { // TODO implement this method - return -1; + if (max == -1) { + max = Integer.MAX_VALUE; + } + int total = 0; + int incident; + for (List currentList: records) { + Optional init = atoi(currentList, 3); + if (!init.isPresent()) { + continue; + } + incident = init.get(); + if (incident >= min && incident <= max) { + total += 1; + } + } + return total; } public boolean firstRecordsHaveMoreReportedIndicents(List> records1, List> records2) { // TODO implement this method - return false; + return records1.size() > records2.size(); + } + + public Optional atoi(List curr, int index) { + try { + return Optional.of(Integer.parseInt(curr.get(index))); + } catch (NumberFormatException e) { + return Optional.empty(); + } } } diff --git a/src/main/java/codingcompetition2019/DisasterDescription.java b/src/main/java/codingcompetition2019/DisasterDescription.java index 662626b..a97cafb 100644 --- a/src/main/java/codingcompetition2019/DisasterDescription.java +++ b/src/main/java/codingcompetition2019/DisasterDescription.java @@ -1,5 +1,48 @@ package codingcompetition2019; public class DisasterDescription { - // TODO finish this class + private String category; + private String code; + private String year; + private int significant; + + public DisasterDescription(String category, String code, String year, int significant) { + this.category = category; + this.code = code; + this.year = year; + this.significant = significant; + } + + public void setCategory(String category) { + this.category = category; + } + + public void setCode(String code) { + this.code = code; + } + + public void setYear(String year) { + this.year = year; + } + + public void setSignificant(int significant) { + this.significant = significant; + } + + public String getCategory() { + return category; + } + + public String getCode() { + return code; + } + + public String getYear() { + return year; + } + + public int getReportedIncidentsNum() { + return significant; + } + // TODO finish this class } diff --git a/target/classes/META-INF/MANIFEST.MF b/target/classes/META-INF/MANIFEST.MF new file mode 100644 index 0000000..e4f4546 --- /dev/null +++ b/target/classes/META-INF/MANIFEST.MF @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Built-By: PrimaryUser +Build-Jdk: 10.0.1 +Created-By: Maven Integration for Eclipse + diff --git a/target/classes/META-INF/maven/codingcompetition2019/codingcompetition2019/pom.properties b/target/classes/META-INF/maven/codingcompetition2019/codingcompetition2019/pom.properties new file mode 100644 index 0000000..db71fc3 --- /dev/null +++ b/target/classes/META-INF/maven/codingcompetition2019/codingcompetition2019/pom.properties @@ -0,0 +1,7 @@ +#Generated by Maven Integration for Eclipse +#Sat Oct 05 22:55:38 EDT 2019 +m2e.projectLocation=C\:\\Users\\PrimaryUser\\Documents\\CodingComp +m2e.projectName=codingcompetition2019 +groupId=codingcompetition2019 +artifactId=codingcompetition2019 +version=0.0.1-SNAPSHOT diff --git a/target/classes/META-INF/maven/codingcompetition2019/codingcompetition2019/pom.xml b/target/classes/META-INF/maven/codingcompetition2019/codingcompetition2019/pom.xml new file mode 100644 index 0000000..78eb746 --- /dev/null +++ b/target/classes/META-INF/maven/codingcompetition2019/codingcompetition2019/pom.xml @@ -0,0 +1,26 @@ + + 4.0.0 + + codingcompetition2019 + codingcompetition2019 + 0.0.1-SNAPSHOT + jar + + codingcompetition2019 + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 4.12 + test + + + diff --git a/target/classes/codingcompetition2019/CodingCompCSVUtil.class b/target/classes/codingcompetition2019/CodingCompCSVUtil.class new file mode 100644 index 0000000000000000000000000000000000000000..a1b1ee8c59bbbcaffc5000ca463d27540a2a8861 GIT binary patch literal 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M!?DWVy6dl|8KWoKNs*ZclKME1+d) zgj^@qPN>+AaP^z>OAP_r>IH`Gm4NVcBdoH%x(eAnz$Cd9xu}HVq45V0i-#t>gz&bY zCTmsJek&e4#x4A}p7(jq59rt5(!(F}#J}g=<`0askJ#Y;k%jzE%%6W|*YqJfvcLFH zSnHv%R{37yX)W>F&tu8xha3eczmj-L(QaZyNr4uxUZd~`bEg`GM?~dZ8wJrO1=^N6 zOorN0M`)vG`gaheo!F*qX_uw#)c8!(2Q*pDSW`TPvo7P%zh_XLCzC^HkypCawd-Z$DmR)?7j>V`O?{#C%2xa8FH(o8Uo7N#SL)nDBQMyl;G=&7fqy`) literal 0 HcmV?d00001 diff --git a/target/classes/codingcompetition2019/DisasterDescription.class b/target/classes/codingcompetition2019/DisasterDescription.class new file mode 100644 index 0000000000000000000000000000000000000000..b24b096a436c30df2666578dfacdbd7749edc6d5 GIT binary patch literal 1323 zcma)*U2hUW6o%gc3WY^lpbLfCYSk*cSn=z|kMyRENfS~NF(h6t%ZSs^U9!71>775w z3r!>@Uibt2QO0uyQjji5Z+6bip7WgdytDh~@2}qgo}rmRLcntUzVZgHe>Relij?m? zef;D_>qv!87|GyBhHjune4ar{VExqj?6iiCH)y@>ok}+nSaqF94*cLkpwynd?nD7` zUkRkBgQVp`I)Q)@s)46ID%bI-RvZhYUn@^V2Ldk}SIe(+a%^=8e@I<&NMbDy1M33G zhSkl2H07~^G)EhGWF}E1kJU-EnMW2mfwi{s=yyH22ZKRrxE zpHwK&Y+u_oGQbFBba?5J88amhkl`%t6h|MlSp|wZ^M0iodRSvHPuyr&S8XC7CryA9 zO@LL3-pP?4M6!SExvDR{D5SBqU33?@j(;Aw@{M8#He)`5M|{E9B{!4w5v7n|b16!& zwR$CE^-8wV%Dx-O)AI)HzUX|QZvRBVZjMp3AC6JB_s1}8Gc`u_yRNO#v#vQ=>X9Rg zfdWy=M5$3!r}xjPGiPn#CaoN?5}_m3lF$*WVWoAxW?~6!V`r-7fO0r1t(D9==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8V&8;-41=?vJB?=NN8d9 zKcM-rFEp0v`(8T(hQtg1gJL|ElKEh3YzH4Qz_>SSi~F;%2>ftwG29n%mW^!?3z2Y# zYT@=ZRHm%>h4A-%5PnDe(sp+>k~+LMJ$yqu_~;@2CF3DxhU3pdsD2|^A=EoKgS*t} uJvNe8Jh Date: Sat, 5 Oct 2019 23:09:07 -0400 Subject: [PATCH 2/6] Added Javadocs --- .../CodingCompCSVUtil.java | 39 ++++++++++++++++++ .../CodingCompCSVUtil.class | Bin 7978 -> 7978 bytes 2 files changed, 39 insertions(+) diff --git a/src/main/java/codingcompetition2019/CodingCompCSVUtil.java b/src/main/java/codingcompetition2019/CodingCompCSVUtil.java index 9039806..3fb7cf8 100644 --- a/src/main/java/codingcompetition2019/CodingCompCSVUtil.java +++ b/src/main/java/codingcompetition2019/CodingCompCSVUtil.java @@ -103,6 +103,13 @@ public List> readCSVFileWithoutHeaders(String fileName) throws IOEx return fullList; } + /** + * Produces a DisasterDescription containing information regarding the most impactful year, as measured in the list records. + * + * @param records a list of lists containing all data points with category, code (if applicable), year, and occurrence rate + * @return a DisasterDescription containing the most impactful year by calling setYear() + */ + public DisasterDescription getMostImpactfulYear(List> records) { // TODO implement this method HashMap yearMap = new HashMap(); @@ -126,6 +133,14 @@ public DisasterDescription getMostImpactfulYear(List> records) { return curr; } + /** + * Produces a DisasterDescription containing information regarding the most impactful year from the correct category, as measured in the list records. + * + * @param records a list of lists containing all data points with category, code (if applicable), year, and occurrence rate + * @param category a String containing the category to match with the list + * @return a DisasterDescription containing the most impactful year by calling setYear() + */ + public DisasterDescription getMostImpactfulYearByCategory(String category, List> records) { // TODO implement this method HashMap yearMap = new HashMap(); @@ -152,6 +167,14 @@ public DisasterDescription getMostImpactfulYearByCategory(String category, List< } + /** + * Produces a DisasterDescription containing information regarding the most impactful disaster type with a specified year, as measured in the list records. + * + * @param records a list of lists containing all data points with category, code (if applicable), year, and occurrence rate + * @param year a String containing the year to match with the list + * @return a DisasterDescription containing the most impactful year by calling setYear() + */ + public DisasterDescription getMostImpactfulDisasterByYear(String year, List> records) { // TODO implement this method HashMap disasterMap = new HashMap(); @@ -177,6 +200,14 @@ public DisasterDescription getMostImpactfulDisasterByYear(String year, List> records) { // TODO implement this method int incident = 0; @@ -223,6 +254,14 @@ public int countImpactfulYearsWithReportedIncidentsWithinRange(List return total; } + /** + * Determines if the first record contains more incidents than the second record + * + * @param records1 a list of lists containing all data points with category, code (if applicable), year, and occurrence rate for the first dataset + * @param records2 a list of lists containing all data points with category, code (if applicable), year, and occurrence rate for the second dataset + * @return a boolean describing whether the first record contains more reported incidents + */ + public boolean firstRecordsHaveMoreReportedIndicents(List> records1, List> records2) { // TODO implement this method return records1.size() > records2.size(); diff --git a/target/classes/codingcompetition2019/CodingCompCSVUtil.class b/target/classes/codingcompetition2019/CodingCompCSVUtil.class index a1b1ee8c59bbbcaffc5000ca463d27540a2a8861..4c13356ab7507744f8d3401cabec79348c494ac1 100644 GIT binary patch delta 336 zcmWO2%PWLo6vy%J^On+#-14SLW+4=s(kKg;sfoyj!eW%2g_S6`nB0nuo%eMaw_y^C zky5YAxZf76MJ{16{s59oC^? zyRfbtA(eBD#tjZ`$>5G$?s4%z5sy^yM78vML}}*P3Z^wE*9$Sc%H}t@!MlunkjJNN o{-Tg?xxo)L{8B5uM*ghKbeqzY-OP6eY$}lym4vR6%}b~69~Nj>O#lD@ delta 336 zcmWO2%PYiT6vpxIZ%S#1jY*TtLMSw)Q5G&!6Oj#t#V9)q8;p=!5gEDVHgYMKX$)ad zqhGm(1!e0_C?y;G6Q0iQob!I3w-a$k+)*qlj@znV_6WYMG*eX$F{KRy8jq ztlfPUIA_reBpVjbs+ct~K`|jQ>te!UHpFa-*%Gs@zwQW*u&n$bdm=&{5#@#h^U)qM zvJSCujGYtGI3=4ioXRNRf(kCF)Xd8jja-{+DRqYPmKg4o{Gb~=>B%!WyeRpVeBN|} icdGcHTC;jS&Gb~OVc~l&*Rf>fha`Tn@i%wx@csiCi&gFb From 28b2f9efd7e08bd1edd7d0f5708a3657e69340ab Mon Sep 17 00:00:00 2001 From: Matthew So Date: Sun, 6 Oct 2019 00:21:41 -0400 Subject: [PATCH 3/6] Added special feature --- .idea/CodingComp.iml | 11 ++ .idea/misc.xml | 4 + .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 + .idea/workspace.xml | 241 +++++++++++++++++++++++++++++++++++++++++ feedback.txt | 7 +- src/main/visualizer.py | 36 ++++++ 7 files changed, 310 insertions(+), 3 deletions(-) create mode 100644 .idea/CodingComp.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 src/main/visualizer.py diff --git a/.idea/CodingComp.iml b/.idea/CodingComp.iml new file mode 100644 index 0000000..6711606 --- /dev/null +++ b/.idea/CodingComp.iml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a2e120d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..385248d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..eca2368 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +