WeatherForecast / IWeatherBackend.java
IWeatherBackend.java
Raw
import java.util.NoSuchElementException;
import java.util.Date;
import java.util.List;
/**                                                                                                                                                           
 *This Interface defines methods that must be implemented for the backend of the weather program
 *@author Isaac Bond
 */

import java.util.Date;
import java.util.List;

public interface IWeatherBackend{
    
   /**                                                                                                                                                        
    * This method takes a day as input  gets a snapshot of the days weather                                                                                   
    * @param day a date object with the day to get weather for                                                                                                
    * @throws NoSuchElementException if day does not exist                                                                                                    
    * @return a list of forecast objects which contain data for the weather that day                                                                          
    */
    public List<IForecast> getDay(String day) throws NoSuchElementException;
    
   /**
    * Takes a forecast and adds it to the RB Tree
    * @param forecast a forecast to be added
    */
    public void addForecast(IForecast forecast);

   /**
    * Gets the earliest date avaliable 
    * @return date of the earliest forecast in the database
    */
    public String getClosestDate();
    
   /**
    *Takes in a date object and returns a string
    *@return string representing date obejct
    */
    public String getDateString(Date date);
 
   /**                                                                                                                                                        
    * Takes in a List of forecast objects and averages them                                                                                                   
    * @param day a list of forecast objects to represent the weather for the day                                                                              
    * @return  A forecast object that represents the average weather for that day                                                                             
    */
    public IForecast getAverage(List<IForecast> day);

   /**                                                                                                                                                        
    * Get a list of forecasts to represent a week of weather                                                                                                  
    * @return A list of forecast objects with the average weather for each day in the week                                                                    
    */
    public List<IForecast> getAverageWeek();

   /**                                                                                                                                                        
    * Gets the hottest day in a week                                                                                                                          
    * @param week a list of forecasts object each containing the weather for one day in the week                                                              
    * @return a forecast object with the average weather for the hottest day in the week                                                                      
    */
    public IForecast getHottestDay(List<IForecast> week);

   /**
    * Gets current scale setting
    * @return 'f' if scale is currently fahrenheit and 'c' if scale is currently celsius
    */
    public char getTempUnit();

   /**
    * Gets current speed unit setting
    * @return 'i' for imperial MPH and m for metric speed setting
    */
    public char getSpeedUnit();
    
   /**
    * Sets temp scale for weather app
    * @param unit unit to change temp to
    */ 
    public void setTempUnit(char unit);

   /**
    * Sets temp scale for weatherapp                                                                                                                                                                       
    * @param unit unit to change speed to  
    */
    public void setSpeedUnit(char unit);
    
}