Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
409 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more.
Oops, something went wrong.
11
Agile.iml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package project; | ||
|
||
import javax.swing.*; | ||
import java.io.*; | ||
import java.util.Scanner; | ||
|
||
public class Data { | ||
|
||
protected String year; | ||
protected String totalEnergySupply; | ||
protected String business; | ||
protected String transport; | ||
protected String pub; | ||
protected String residential; | ||
protected String agriculture; | ||
protected String industrial; | ||
protected String waste; | ||
protected String totalCO2; | ||
protected String otherGases; | ||
protected String totalGHG; | ||
|
||
//constructor | ||
public Data(String year, String totalEnergySupply, String business, String transport, | ||
String pub, String residential, String agriculture, String industrial, | ||
String waste, String totalCO2, String otherGases, String totalGHG) { | ||
|
||
this.year = year; | ||
this.totalEnergySupply = totalEnergySupply; | ||
this.business = business; | ||
this.transport = transport; | ||
this.pub = pub; | ||
this.residential = residential; | ||
this.agriculture = agriculture; | ||
this.industrial = industrial; | ||
this.waste = waste; | ||
this.totalCO2 = totalCO2; | ||
this.otherGases = otherGases; | ||
this.totalGHG = totalGHG; | ||
} | ||
|
||
//method for reading info on .txt file | ||
public static void readData(String searchTerm, String filepath) { | ||
|
||
boolean found = false; | ||
String year = ""; | ||
String totalEnergySupply = ""; | ||
String business = ""; | ||
String transport = ""; | ||
String pub = ""; | ||
String residential = ""; | ||
String agriculture = ""; | ||
String industrial = ""; | ||
String waste = ""; | ||
String totalCO2 = ""; | ||
String otherGases = ""; | ||
String totalGHG = ""; | ||
|
||
try { | ||
|
||
Scanner x = new Scanner(new File(filepath)); | ||
x.useDelimiter("[,\n]"); | ||
|
||
while (x.hasNextLine() && !found) { | ||
year = x.next(); | ||
totalEnergySupply = x.next(); | ||
business = x.next(); | ||
transport = x.next(); | ||
pub = x.next(); | ||
residential = x.next(); | ||
agriculture = x.next(); | ||
industrial = x.next(); | ||
waste = x.next(); | ||
totalCO2 = x.next(); | ||
otherGases = x.next(); | ||
totalGHG = x.next(); | ||
|
||
if (year.equals(searchTerm)) { | ||
|
||
found = true; | ||
} | ||
} | ||
|
||
if (found) { //if date equals name on .txt line print info from that line on the pop-up window | ||
|
||
JOptionPane.showMessageDialog(null, "Year: " + year + ", " + "Energy Supply: " + totalEnergySupply + ", " + "Business: " + | ||
business + ", " + "Transport: " + transport + ", " + "Public Sector: " + pub + ", " + "Residential: " + residential + ", " + "Agriculture: " + agriculture + ", " + | ||
"Industrial: " + industrial + ", " + "Waste: " + waste + ", " + "Total CO2: " + totalCO2 + ", " + "Other Gases: " + otherGases + ", " + "Total GHG: " + totalGHG); | ||
|
||
} else { //if no name equals search term | ||
|
||
JOptionPane.showMessageDialog(null, "Not found"); | ||
|
||
} | ||
|
||
} catch (Exception e) { | ||
|
||
JOptionPane.showMessageDialog(null, "Operation Failed"); | ||
} | ||
} | ||
} |
Oops, something went wrong.