api keys
This commit is contained in:
parent
7b6b15d1d2
commit
840dbecdea
@ -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,13 +80,15 @@ 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();
|
||||
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
@ -26,6 +28,11 @@ public class Questions {
|
||||
p.getEdu().addCourses(list);
|
||||
Print(p);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.out.print(" Error in input. \n");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static String askForName(Scanner in) {
|
||||
String name = null;
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user