This commit is contained in:
hesham 2019-02-12 03:46:50 +03:00
parent 7b6b15d1d2
commit 840dbecdea
2 changed files with 33 additions and 5 deletions

View File

@ -16,6 +16,7 @@ public class Location {
private double latitude;
private double longitude;
private String city;
private String lastInfoString;
public Location(double lat, double lon) {
latitude = lat;
@ -79,15 +80,17 @@ public class Location {
JSONArray array=(JSONArray)resultObject;
for (Object object : array) {
JSONObject obj =(JSONObject)object;
city = (String)obj.get("city");
city = (String)obj.get(API_Keys.city.name());
lastInfoString = (String)obj.toString();
}
}
else if (resultObject instanceof JSONObject) {
JSONObject obj =(JSONObject)resultObject;
city = (String)obj.get("city");
city = (String)obj.get(API_Keys.city.name());
lastInfoString = (String)obj.toString();
}
}
}
catch (MalformedURLException e) {
e.printStackTrace();
@ -103,4 +106,22 @@ public class Location {
}
return city;
}
private enum API_Keys {
zip,
country,
city,
org,
timezone,
isp,
quary,
regionName,
lon,
lat,
as,
countryCode,
region,
status
}
}

View File

@ -9,6 +9,8 @@ public class Questions {
public static void run(){
try {
Person p = new Person(12345, "Hesham", Level.BA);
System.out.println("-------------------------------------------------");
Scanner in = new Scanner(System.in);
@ -25,6 +27,11 @@ public class Questions {
List<Course> list = Arrays.asList(Course.EE201, Course.EE250,Course.ISLS201);
p.getEdu().addCourses(list);
Print(p);
}
catch (Exception ex) {
System.out.print(" Error in input. \n");
ex.printStackTrace();
}
}
private static String askForName(Scanner in) {
@ -65,7 +72,7 @@ public class Questions {
/**
* Finds the correct enum value of the parameter.
* @param a string naming the account type
* @param string naming the account type
* @return AccountType
* @since 0.1
* @exception IncorrectStringException