import java.util.ArrayList;

public class WeatherData {

	// change the access specifier from private to package, so that
	// it is accessible in the Runner class
	ArrayList<Double> temperatures;
	
	public WeatherData()
	{
		//initialize ArrayList
		temperatures = new ArrayList<Double>();
	}
	
	public void cleanData(double lower, double upper)
	{
		for (int i=0; i< temperatures.size(); i++)
		{
			if ((temperatures.get(i) < lower) || (temperatures.get(i) > upper))
			{
				temperatures.remove(i);
			}
		}
	}
	
	public int longestHeatWave(double threshold)
	{
		int length=0;
		int maxLength=0;
		int index=0;
		boolean exit=false;
		for (int i=0; i< temperatures.size(); i++)
		{
			length=0;
			index=0;
			if (temperatures.get(i)> threshold)
			{
				index =i+1;
				length++;
				exit=false;
				for (; index < temperatures.size() && !exit; index++)
				{
					if (temperatures.get(index)> threshold) length++;
					else
					{
						// exit from this loop
						exit = true;
					}
				}
			}
			
			if (maxLength < length) maxLength=length;
		}
		
		return maxLength;
	}
}
