import java.util.ArrayList;

public class ReviewAnalysis {

	//changing the access so that it is visible in the Runner class
	Review[] allReviews;
	
	public ReviewAnalysis()
	{
	}
	
	public double getAverageRating()
	{
		int sum=0;
		for (int i=0; i< allReviews.length; i++)
		{
			sum = sum + allReviews[i].getRating();
		}
		return ((double)sum/allReviews.length);
	}
	
	public ArrayList<String> collectComments()
	{
		ArrayList<String> arr = new ArrayList<String>();
		String str= "";
		
		for (int i=0; i < allReviews.length; i++)
		{
			str= "";
			if (allReviews[i].getComment().indexOf("!") != -1)
			{
				//found; form the string and add to arraylist
				str = i+"-"+allReviews[i].getComment();	
			
			if (!allReviews[i].getComment().endsWith(".") && !allReviews[i].getComment().endsWith("!"))
			{
				str = str + ".";
			}

			arr.add(str);
			}
		}
		
		return arr;
	}
	

}
