package ca.teamTen.recitopia;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Queue;

import android.content.Context;

// This class stores a limited number of recipes that are not created by current user
public class LocalCache implements RecipeBook{

	private Queue<Recipe> recipeQueue;
	
	@Override
	public Recipe[] query(String[] ingredients, String title, String user) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void addRecipe(Recipe recipe) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void save(String fileName, Context ctx) {
		// TODO Auto-generated method stub
		try {  
			FileOutputStream fos = ctx.openFileOutput(fileName,Context.MODE_PRIVATE);
			ObjectOutputStream out = new ObjectOutputStream(fos);
			out.writeObject(recipeQueue);
			out.close();  
		} catch (FileNotFoundException e) {  
			e.printStackTrace();  

		} catch (IOException e) {  
			e.printStackTrace();  
		}  
	}
	
	public void load(String fileName, Context ctx) {
		try {  
			FileInputStream fis = ctx.openFileInput(fileName);
			ObjectInputStream in = new ObjectInputStream(fis);  
			this.recipeQueue = (Queue<Recipe>) in.readObject();
			in.close();
		} 
		catch (IOException e) {  
			e.printStackTrace();  
		} catch (ClassNotFoundException e) {  
			e.printStackTrace();  
		}  
	}

}

@@ -252,16 +252,45 @@
 ayList;%0A
+import java.util.LinkedList;%0A
 import j
@@ -339,18 +339,24 @@
 ntext;%0A%0A
-//
+%0A/**%0A * 
  This cl
@@ -431,16 +431,24 @@
 nt user%0A
+ * %0A */%0A
 public c
@@ -513,21 +513,164 @@
 ipe%3E
- recipeQueue;
+%09recipeQueue;%0A%09private int%09%09%09maxEntries;%0A%09%0A%09public LocalCache(int maxEntries) %7B%0A%09%09recipeQueue = new LinkedList%3CRecipe%3E();%0A%09%09this.maxEntries = maxEntries;%0A%09%7D
 %0A%09%0A%09

Modify LocalCache to take max entries in ctor.