weather skill

fukurou

Administrator
String string = "004-004";
String[] parts = string.split("-");

if (parts.length == 2) {
if(parts[0].contains(parts[1]))
System.out.println(parts[1]);
}
System.out.println("jizz");
 

fukurou

Administrator
a new alg part is created, summon of APSayArgs : says param array verbatim

Java:
package chobit;

import java.util.ArrayList;

public class APSayArgs extends AbsAlgPart {
    ArrayList<String> sentences = new ArrayList<String>();
    private int at = 0;

    public APSayArgs(String... sentences) {
        for (int i = 0; i < sentences.length; i++) {
            this.sentences.add(sentences[i]);
        }
        if (0 == sentences.length) {
            at = 30;
        }
    }

    public APSayArgs(ArrayList<String> list1) {
        this.sentences = new ArrayList<String>(list1);
        if (0 == this.sentences.size()) {
            at = 30;
        }
    }

    @Override
    public String action(String ear, String skin, String eye) {
        // TODO Auto-generated method stub
        String axnStr = "";
        if (this.at < this.sentences.size()) {
            axnStr = this.sentences.get(at);
            at++;
        }
        return axnStr;
    }

    @Override
    public enumFail failure(String input) {
        // TODO Auto-generated method stub
        return enumFail.ok;
    }

    @Override
    public Boolean completed() {
        // TODO Auto-generated method stub
        return at >= this.sentences.size();
    }

    @Override
    public AbsAlgPart clone() {
        // TODO Auto-generated method stub
        return new APSayArgs(this.sentences);
    }

    @Override
    public Boolean itemize() {
        // TODO add logic
        // at home
        return true;
    }
}
 

fukurou

Administrator
static
vars :
degrees
cur weather
alert level

***************************

input :

if input.contains(weather) {
get weather; }

*******************************
output :

if weather update : APVerbatim(getWeatherlist);
 

fukurou

Administrator
Java:
package com.yotamarker.lgkotlin1;

import android.os.AsyncTask;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONObject;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;

public class Weather {
    private static Double degrees = 0.0;
    private static String currentWeather = "unknown";
    private static String weatherWarning = "sunny weather";
    private static Boolean hasBeenUpdated = false;

    public static void updateWeather(String city) {
        DownloadTask task = new DownloadTask();
        Coordinates xyTitan = cityToCoordinates(city);
        String s1 = String.format(
                "http://openweathermap.org/data/2.5/weather?lat=%.04f&lon=%.04f&appid=b6907d289e10d714a6e88b30761fae22",
                xyTitan.getX(), xyTitan.getY());
        task.execute(s1);

    }
    private static  Coordinates cityToCoordinates(String city){
        switch (city) {
            case "pripyat":
                return  new Coordinates(51.4061, 30.0571);
            default:
//default statement sequence
        }
        return  new Coordinates(32.0809, 34.7806); // replace with GPS
    }
    public static ArrayList<String> getWeatherList() {
        // returns vital weather info
        ArrayList<String> result = new ArrayList<String>();
        result.add(decorateDegrees(degrees));
        result.add(currentWeather);
        result.add(weatherWarning);
        hasBeenUpdated = false;
        return result;
    }
    private static String decorateDegrees(Double degrees){
            if(degrees >3 && degrees < 14){return  "cold brrr";}
            else if(degrees > 25 && degrees < 30){return "it is hot";}
        return  degrees +"";
    }

    public static Boolean getHasBeenUpdated() {
        return hasBeenUpdated;
    }
    public static class DownloadTask extends AsyncTask<String,Void,String> {

        @Override
        protected String doInBackground(String... urls) {
            String result = "";
            URL url;
            HttpURLConnection urlConnection = null;

            try {

                url = new URL(urls[0]);
                urlConnection = (HttpURLConnection) url.openConnection();
                InputStream in = urlConnection.getInputStream();
                InputStreamReader reader = new InputStreamReader(in);
                int data = reader.read();

                while (data != -1) {
                    char current = (char) data;
                    result += current;
                    data = reader.read();
                }

                return result;

            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
        }

        @Override
        protected void onPostExecute(String s) {
            super.onPostExecute(s);

            try {
                JSONObject jsonObject = new JSONObject(s);

                String weatherInfo = jsonObject.getString("weather");

                //Log.i("Weather content", weatherInfo);

                JSONArray arr = new JSONArray(weatherInfo);

                for (int i=0; i < arr.length(); i++) {
                    JSONObject jsonPart = arr.getJSONObject(i);
                    weatherWarning = jsonPart.getString("main");
                    //Log.i("main",weatherWarning);
                    currentWeather = jsonPart.getString("description");
                    //Log.i("description",jsonPart.getString("description"));

                }
                String temp = jsonObject.getString("main");
                JSONObject jsonObject2 = new JSONObject(temp);
                //degrees = jsonObject2.getString("temp");
                degrees = jsonObject2.getDouble("temp");
                hasBeenUpdated = true;
                //Log.i("maalot",temp);
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
    }
}
 

fukurou

Administrator

so now I want to dev a GPS coordinates getter, which would also be useful for other shit like travel as well as get the weather
at current location
 
Top