Skip to content
Snippets Groups Projects
Commit 9e1e34ad authored by Haug Michael's avatar Haug Michael
Browse files

renamed classes and methods, cleaned up main

parent cd313448
No related branches found
No related tags found
No related merge requests found
package de.hdm_stuttgart.mi.sd1.weather;
import de.hdm_stuttgart.mi.sd1.weather.cities.Cities;
import de.hdm_stuttgart.mi.sd1.weather.cities.City;
import de.hdm_stuttgart.mi.sd1.weather.model.*;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;
/**
* Providing terminal based weather forecast
......@@ -24,31 +16,17 @@ public class Forecast {
*
* @param args Yet unused.
*/
public static void main(String[] args) throws IOException {
/* Scanner scanName = new Scanner(System.in);
public static void main(String[] args){
String eingabeStadt = scanName.next(); */
SearchingAndComparing.MethodSearchingAndComparing();
/* for(int i =0; i < 20; i++)
{
City city = Cities.cities[i];
CopyToFile.CopyURLToFile();
System.out.println(city.getName());
System.out.println(city.getCountry());
System.out.println(city.getId() + "\n");
}
*/
CopyToFile.CopyFileToWeather();
SearchingAndComparing.searchingAndComparing();
WeatherOutput.PrintWeather();
CopyToFile.FileMethod();
Weather weathertest = WeatherDataParser.parse(CopyToFile.FileMethod());
/* java.net.URL
// System.out.println(SearchingAndComparing.searchingAndComparing());
String test = "https://api.openweathermap.org/data/2.5/forecast?lang=de&APPID=7cufdhdcgdhsgdhgfcgsdss67b3&units=metric&id=3214105";
FileUtils.copyURLToFile(test, new File("weatherData.json")); */
}
}
package de.hdm_stuttgart.mi.sd1.weather.model;
import de.hdm_stuttgart.mi.sd1.weather.WeatherDataParser;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
public class CopyToFile {
public static String CopyURLToFile() {
try {
FileUtils.copyURLToFile(
URLCreator.CreateUrl(),
new File("weatherData.json"));
} catch (IOException e) {
System.out.println("ERROR");
}
return "weatherData.json";
}
public static Weather CopyFileToWeather () {
Weather weatherObject = null;
try {
weatherObject = WeatherDataParser.parse(CopyToFile.CopyURLToFile());
} catch (IOException e) {
System.out.println("ERROR");
}
return weatherObject;
}
}
\ No newline at end of file
......@@ -8,7 +8,10 @@ import java.util.Scanner;
public class SearchingAndComparing {
static public int searchingAndComparing() {
static public int MethodSearchingAndComparing() {
/* System.out.println("Please enter your City: ");
Scanner scan = new Scanner(System.in);
String searchedCity = scan.nextLine(); */
String searchedCity = "Republic of India";
/**
......@@ -23,7 +26,7 @@ public class SearchingAndComparing {
System.out.println("please type in a city you want weatherdata for");
} else {
for (int i = 0; i < /* <= ? */ Cities.cities.length; i++) {
for (int i = 0; i <= Cities.cities.length-1; i++) {
City createdCity = Cities.cities[i];
if (searchedCity.equals(createdCity.getName())) {
citySelector[k] = createdCity;
......@@ -61,7 +64,7 @@ public class SearchingAndComparing {
}
}
return 0;
return citySelector[0].getId();
}
......
......@@ -5,8 +5,8 @@ import java.net.URL;
public class URLCreator {
public URL CreateUrl (int id) throws MalformedURLException {
URL linkWithId = new URL("http://www.google.com");
public static URL CreateUrl () throws MalformedURLException {
URL linkWithId = new URL("https://api.openweathermap.org/data/2.5/forecast?lang=de&APPID=41d009d32d4e302e0cd3d0f55bf5da24&units=metric&id="+ SearchingAndComparing.MethodSearchingAndComparing());
return linkWithId;
}
}
package de.hdm_stuttgart.mi.sd1.weather.model;
public class WeatherOutput {
public static String PrintWeather(){
return "";
}
}
{"cod":"200","message":0.0034,"cnt":40,"list":[{"dt":1528912800,"main":{"temp":27.65,"temp_min":27.36,"temp_max":27.65,"pressure":960.83,"sea_level":1015.88,"grnd_level":960.83,"humidity":59,"temp_kf":0.29},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"02n"}],"clouds":{"all":8},"wind":{"speed":5.81,"deg":275.506},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-13 18:00:00"},{"dt":1528923600,"main":{"temp":26.15,"temp_min":25.93,"temp_max":26.15,"pressure":960.24,"sea_level":1015.3,"grnd_level":960.24,"humidity":67,"temp_kf":0.22},"weather":[{"id":801,"main":"Clouds","description":"Ein paar Wolken","icon":"02n"}],"clouds":{"all":20},"wind":{"speed":5.82,"deg":274},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-13 21:00:00"},{"dt":1528934400,"main":{"temp":24.49,"temp_min":24.35,"temp_max":24.49,"pressure":960.68,"sea_level":1015.85,"grnd_level":960.68,"humidity":80,"temp_kf":0.15},"weather":[{"id":801,"main":"Clouds","description":"Ein paar Wolken","icon":"02n"}],"clouds":{"all":20},"wind":{"speed":5.32,"deg":268.002},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-14 00:00:00"},{"dt":1528945200,"main":{"temp":27.86,"temp_min":27.79,"temp_max":27.86,"pressure":961.53,"sea_level":1016.51,"grnd_level":961.53,"humidity":69,"temp_kf":0.07},"weather":[{"id":500,"main":"Rain","description":"Leichter Regen","icon":"10d"}],"clouds":{"all":64},"wind":{"speed":5.91,"deg":267.502},"rain":{"3h":0.015},"sys":{"pod":"d"},"dt_txt":"2018-06-14 03:00:00"},{"dt":1528956000,"main":{"temp":32.81,"temp_min":32.81,"temp_max":32.81,"pressure":960.9,"sea_level":1015.49,"grnd_level":960.9,"humidity":52,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"01d"}],"clouds":{"all":0},"wind":{"speed":5.81,"deg":275},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-14 06:00:00"},{"dt":1528966800,"main":{"temp":36.05,"temp_min":36.05,"temp_max":36.05,"pressure":959.01,"sea_level":1013.36,"grnd_level":959.01,"humidity":41,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"02d"}],"clouds":{"all":8},"wind":{"speed":5.16,"deg":273.501},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-14 09:00:00"},{"dt":1528977600,"main":{"temp":35.75,"temp_min":35.75,"temp_max":35.75,"pressure":957.84,"sea_level":1012.19,"grnd_level":957.84,"humidity":36,"temp_kf":0},"weather":[{"id":801,"main":"Clouds","description":"Ein paar Wolken","icon":"02d"}],"clouds":{"all":20},"wind":{"speed":4.91,"deg":276.502},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-14 12:00:00"},{"dt":1528988400,"main":{"temp":26.79,"temp_min":26.79,"temp_max":26.79,"pressure":959.63,"sea_level":1014.23,"grnd_level":959.63,"humidity":70,"temp_kf":0},"weather":[{"id":500,"main":"Rain","description":"Leichter Regen","icon":"10n"}],"clouds":{"all":24},"wind":{"speed":3.47,"deg":274.001},"rain":{"3h":0.755},"sys":{"pod":"n"},"dt_txt":"2018-06-14 15:00:00"},{"dt":1528999200,"main":{"temp":27.05,"temp_min":27.05,"temp_max":27.05,"pressure":960.67,"sea_level":1015.7,"grnd_level":960.67,"humidity":62,"temp_kf":0},"weather":[{"id":500,"main":"Rain","description":"Leichter Regen","icon":"10n"}],"clouds":{"all":24},"wind":{"speed":5.76,"deg":281.01},"rain":{"3h":0.285},"sys":{"pod":"n"},"dt_txt":"2018-06-14 18:00:00"},{"dt":1529010000,"main":{"temp":25.98,"temp_min":25.98,"temp_max":25.98,"pressure":960.19,"sea_level":1015.21,"grnd_level":960.19,"humidity":66,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"02n"}],"clouds":{"all":8},"wind":{"speed":5.65,"deg":283.001},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-14 21:00:00"},{"dt":1529020800,"main":{"temp":24.08,"temp_min":24.08,"temp_max":24.08,"pressure":960.88,"sea_level":1016.02,"grnd_level":960.88,"humidity":81,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"01n"}],"clouds":{"all":0},"wind":{"speed":4.55,"deg":277.507},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-15 00:00:00"},{"dt":1529031600,"main":{"temp":27.73,"temp_min":27.73,"temp_max":27.73,"pressure":962.43,"sea_level":1017.41,"grnd_level":962.43,"humidity":69,"temp_kf":0},"weather":[{"id":801,"main":"Clouds","description":"Ein paar Wolken","icon":"02d"}],"clouds":{"all":24},"wind":{"speed":5.46,"deg":267.001},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-15 03:00:00"},{"dt":1529042400,"main":{"temp":32.81,"temp_min":32.81,"temp_max":32.81,"pressure":962,"sea_level":1016.6,"grnd_level":962,"humidity":53,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"01d"}],"clouds":{"all":0},"wind":{"speed":6.01,"deg":277.001},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-15 06:00:00"},{"dt":1529053200,"main":{"temp":35.37,"temp_min":35.37,"temp_max":35.37,"pressure":960.16,"sea_level":1014.6,"grnd_level":960.16,"humidity":43,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"02d"}],"clouds":{"all":8},"wind":{"speed":5.67,"deg":275.507},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-15 09:00:00"},{"dt":1529064000,"main":{"temp":34.99,"temp_min":34.99,"temp_max":34.99,"pressure":959.36,"sea_level":1013.85,"grnd_level":959.36,"humidity":37,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"02d"}],"clouds":{"all":8},"wind":{"speed":5.55,"deg":275},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-15 12:00:00"},{"dt":1529074800,"main":{"temp":31.6,"temp_min":31.6,"temp_max":31.6,"pressure":961.33,"sea_level":1016.1,"grnd_level":961.33,"humidity":43,"temp_kf":0},"weather":[{"id":802,"main":"Clouds","description":"Überwiegend bewölkt","icon":"03n"}],"clouds":{"all":36},"wind":{"speed":4.56,"deg":266},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-15 15:00:00"},{"dt":1529085600,"main":{"temp":29.36,"temp_min":29.36,"temp_max":29.36,"pressure":962.86,"sea_level":1017.82,"grnd_level":962.86,"humidity":51,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"01n"}],"clouds":{"all":0},"wind":{"speed":5.87,"deg":276.501},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-15 18:00:00"},{"dt":1529096400,"main":{"temp":26.49,"temp_min":26.49,"temp_max":26.49,"pressure":962.58,"sea_level":1017.77,"grnd_level":962.58,"humidity":65,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"01n"}],"clouds":{"all":0},"wind":{"speed":5.86,"deg":275.501},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-15 21:00:00"},{"dt":1529107200,"main":{"temp":24.59,"temp_min":24.59,"temp_max":24.59,"pressure":963.19,"sea_level":1018.45,"grnd_level":963.19,"humidity":76,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"01n"}],"clouds":{"all":0},"wind":{"speed":4.86,"deg":268.5},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-16 00:00:00"},{"dt":1529118000,"main":{"temp":28.43,"temp_min":28.43,"temp_max":28.43,"pressure":964.13,"sea_level":1019.31,"grnd_level":964.13,"humidity":63,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"01d"}],"clouds":{"all":0},"wind":{"speed":5.62,"deg":267},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-16 03:00:00"},{"dt":1529128800,"main":{"temp":32.97,"temp_min":32.97,"temp_max":32.97,"pressure":963.63,"sea_level":1018.41,"grnd_level":963.63,"humidity":50,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"01d"}],"clouds":{"all":0},"wind":{"speed":5.95,"deg":275.007},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-16 06:00:00"},{"dt":1529139600,"main":{"temp":35.41,"temp_min":35.41,"temp_max":35.41,"pressure":961.53,"sea_level":1016.02,"grnd_level":961.53,"humidity":42,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"02d"}],"clouds":{"all":8},"wind":{"speed":5.31,"deg":277.003},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-16 09:00:00"},{"dt":1529150400,"main":{"temp":33.74,"temp_min":33.74,"temp_max":33.74,"pressure":960.69,"sea_level":1015.32,"grnd_level":960.69,"humidity":40,"temp_kf":0},"weather":[{"id":500,"main":"Rain","description":"Leichter Regen","icon":"10d"}],"clouds":{"all":64},"wind":{"speed":5.72,"deg":275.5},"rain":{"3h":0.03},"sys":{"pod":"d"},"dt_txt":"2018-06-16 12:00:00"},{"dt":1529161200,"main":{"temp":30.76,"temp_min":30.76,"temp_max":30.76,"pressure":962.55,"sea_level":1017.51,"grnd_level":962.55,"humidity":47,"temp_kf":0},"weather":[{"id":500,"main":"Rain","description":"Leichter Regen","icon":"10n"}],"clouds":{"all":44},"wind":{"speed":5.01,"deg":272.503},"rain":{"3h":0.04},"sys":{"pod":"n"},"dt_txt":"2018-06-16 15:00:00"},{"dt":1529172000,"main":{"temp":28.77,"temp_min":28.77,"temp_max":28.77,"pressure":964.06,"sea_level":1019.13,"grnd_level":964.06,"humidity":56,"temp_kf":0},"weather":[{"id":801,"main":"Clouds","description":"Ein paar Wolken","icon":"02n"}],"clouds":{"all":12},"wind":{"speed":5.92,"deg":266.5},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-16 18:00:00"},{"dt":1529182800,"main":{"temp":26.13,"temp_min":26.13,"temp_max":26.13,"pressure":963.57,"sea_level":1018.78,"grnd_level":963.57,"humidity":68,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"02n"}],"clouds":{"all":8},"wind":{"speed":5.91,"deg":272.501},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-16 21:00:00"},{"dt":1529193600,"main":{"temp":24.49,"temp_min":24.49,"temp_max":24.49,"pressure":963.89,"sea_level":1019.24,"grnd_level":963.89,"humidity":77,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"01n"}],"clouds":{"all":0},"wind":{"speed":4.91,"deg":274.001},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-17 00:00:00"},{"dt":1529204400,"main":{"temp":28.25,"temp_min":28.25,"temp_max":28.25,"pressure":965.12,"sea_level":1020.32,"grnd_level":965.12,"humidity":63,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"01d"}],"clouds":{"all":0},"wind":{"speed":5.81,"deg":270.007},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-17 03:00:00"},{"dt":1529215200,"main":{"temp":32.73,"temp_min":32.73,"temp_max":32.73,"pressure":964.34,"sea_level":1019.15,"grnd_level":964.34,"humidity":50,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"01d"}],"clouds":{"all":0},"wind":{"speed":6.61,"deg":278.002},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-17 06:00:00"},{"dt":1529226000,"main":{"temp":35.14,"temp_min":35.14,"temp_max":35.14,"pressure":961.74,"sea_level":1016.25,"grnd_level":961.74,"humidity":43,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"02d"}],"clouds":{"all":8},"wind":{"speed":6.31,"deg":280.502},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-17 09:00:00"},{"dt":1529236800,"main":{"temp":32.92,"temp_min":32.92,"temp_max":32.92,"pressure":960.97,"sea_level":1015.53,"grnd_level":960.97,"humidity":46,"temp_kf":0},"weather":[{"id":500,"main":"Rain","description":"Leichter Regen","icon":"10d"}],"clouds":{"all":48},"wind":{"speed":6.11,"deg":285.5},"rain":{"3h":0.65},"sys":{"pod":"d"},"dt_txt":"2018-06-17 12:00:00"},{"dt":1529247600,"main":{"temp":31.26,"temp_min":31.26,"temp_max":31.26,"pressure":961.98,"sea_level":1016.77,"grnd_level":961.98,"humidity":46,"temp_kf":0},"weather":[{"id":803,"main":"Clouds","description":"Überwiegend bewölkt","icon":"04n"}],"clouds":{"all":76},"wind":{"speed":5.35,"deg":278.001},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-17 15:00:00"},{"dt":1529258400,"main":{"temp":29.86,"temp_min":29.86,"temp_max":29.86,"pressure":962.97,"sea_level":1017.8,"grnd_level":962.97,"humidity":52,"temp_kf":0},"weather":[{"id":802,"main":"Clouds","description":"Überwiegend bewölkt","icon":"03n"}],"clouds":{"all":44},"wind":{"speed":5.62,"deg":275.501},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-17 18:00:00"},{"dt":1529269200,"main":{"temp":27,"temp_min":27,"temp_max":27,"pressure":962.19,"sea_level":1017.2,"grnd_level":962.19,"humidity":64,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"01n"}],"clouds":{"all":0},"wind":{"speed":5.66,"deg":279.005},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-17 21:00:00"},{"dt":1529280000,"main":{"temp":24.96,"temp_min":24.96,"temp_max":24.96,"pressure":962.28,"sea_level":1017.52,"grnd_level":962.28,"humidity":74,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"01n"}],"clouds":{"all":0},"wind":{"speed":4.46,"deg":267.502},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-18 00:00:00"},{"dt":1529290800,"main":{"temp":28.63,"temp_min":28.63,"temp_max":28.63,"pressure":963.24,"sea_level":1018.31,"grnd_level":963.24,"humidity":62,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"Klarer Himmel","icon":"01d"}],"clouds":{"all":0},"wind":{"speed":5.7,"deg":265.504},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-18 03:00:00"},{"dt":1529301600,"main":{"temp":32.85,"temp_min":32.85,"temp_max":32.85,"pressure":962.52,"sea_level":1017.19,"grnd_level":962.52,"humidity":51,"temp_kf":0},"weather":[{"id":802,"main":"Clouds","description":"Überwiegend bewölkt","icon":"03d"}],"clouds":{"all":36},"wind":{"speed":6.06,"deg":277.502},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-18 06:00:00"},{"dt":1529312400,"main":{"temp":34.85,"temp_min":34.85,"temp_max":34.85,"pressure":960.01,"sea_level":1014.49,"grnd_level":960.01,"humidity":44,"temp_kf":0},"weather":[{"id":802,"main":"Clouds","description":"Überwiegend bewölkt","icon":"03d"}],"clouds":{"all":32},"wind":{"speed":5.36,"deg":276.503},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-18 09:00:00"},{"dt":1529323200,"main":{"temp":34.45,"temp_min":34.45,"temp_max":34.45,"pressure":959.16,"sea_level":1013.62,"grnd_level":959.16,"humidity":40,"temp_kf":0},"weather":[{"id":802,"main":"Clouds","description":"Überwiegend bewölkt","icon":"03d"}],"clouds":{"all":48},"wind":{"speed":5.61,"deg":281.001},"rain":{},"sys":{"pod":"d"},"dt_txt":"2018-06-18 12:00:00"},{"dt":1529334000,"main":{"temp":31,"temp_min":31,"temp_max":31,"pressure":960.83,"sea_level":1015.61,"grnd_level":960.83,"humidity":49,"temp_kf":0},"weather":[{"id":802,"main":"Clouds","description":"Überwiegend bewölkt","icon":"03n"}],"clouds":{"all":32},"wind":{"speed":5.16,"deg":286.502},"rain":{},"sys":{"pod":"n"},"dt_txt":"2018-06-18 15:00:00"}],"city":{"id":1269750,"name":"Republic of India","coord":{"lat":20,"lon":77},"country":"IN"}}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment