コード例 #1
0
        private static void ClimaCellAPI()
        {
            string cityName = "Stuart";

            ClimaCellController climaCellController = new ClimaCellController();

            Console.WriteLine("**** ClimaCell ****");
            Console.WriteLine("**** Current Weather API ****");
            Console.WriteLine($"Current Temperature for {cityName}: {climaCellController.getCurrentWeather(cityName)}");

            Console.WriteLine("***** Forecast API *****");
            Console.WriteLine($"Forecast for {cityName}: ");
            foreach (ClimaCellForecast forecast in climaCellController.getForecast(cityName))
            {
                Console.WriteLine($"{forecast.getDate()} Minimum: {forecast.getMinimum()} Maximum: {forecast.getMaximum()}");
            }
        }
コード例 #2
0
        static void climaCellCurrentAPI()
        {
            Out output = new Out();

            ClimaCellController climaCellController = new ClimaCellController();

            output.outputToConsole("\n**** ClimaCell Current Weather ****");

            AccuWeatherController accuWeatherController = new AccuWeatherController();

            string cityName  = "Valletta";
            string position  = accuWeatherController.getLocationGeoPosition(cityName);
            string latitude  = position.Substring(0, position.IndexOf(','));
            string longitude = position.Substring(position.IndexOf(',') + 1);

            output.outputToConsole($"Temperature for {cityName}: {climaCellController.getCurrentWeather(latitude, longitude, EndpointTypes.CURRENT)}");
        }
コード例 #3
0
        static void climaCellForecastAPI()
        {
            Out output = new Out();

            ClimaCellController climaCellController = new ClimaCellController();

            output.outputToConsole("\n**** ClimaCell Forecast ****");

            AccuWeatherController accuWeatherController = new AccuWeatherController();

            string cityName  = "Valletta";
            string position  = accuWeatherController.getLocationGeoPosition(cityName);
            string latitude  = position.Substring(0, position.IndexOf(','));
            string longitude = position.Substring(position.IndexOf(',') + 1);

            foreach (ClimaCellForecast forecast in climaCellController.getForecast(latitude, longitude, EndpointTypes.FORECAST))
            {
                output.outputToConsole($"Date: {forecast.getDateTime()} Value: {forecast.getValue()} Units: {forecast.getUnits()}");
            }
        }