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 android.content.Context;
import android.util.Log;

public class Fridge{

	private ArrayList<String> ingredients;
	
	public Fridge() {
		ingredients = new ArrayList();
	}
	
	public void addIngredient(String ingredient) {
		ingredients.add(ingredient);
	}
	
	public void removeIngredient(int index) {
		ingredients.remove(index);
	}
	
	public void saveFridgeInfo(String fileName, Context ctx) {
		try {  
			FileOutputStream fos = ctx.openFileOutput(fileName,Context.MODE_PRIVATE);
			ObjectOutputStream out = new ObjectOutputStream(fos);
			out.writeObject(ingredients);
			out.close();  
		} catch (FileNotFoundException e) {  
			e.printStackTrace();  

		} catch (IOException e) {  
			e.printStackTrace();  
		}  
	}
	
	public void loadFridgeInfo(String fileName, Context ctx) {
		try {  
			FileInputStream fis = ctx.openFileInput(fileName);
			ObjectInputStream in = new ObjectInputStream(fis);  
			this.ingredients = (ArrayList<String>) in.readObject();
			Log.v("Read", "Read");
			in.close();
		} 
		catch (IOException e) {  
			e.printStackTrace();  
		} catch (ClassNotFoundException e) {  
			e.printStackTrace();  
		}  
	}
}

@@ -256,66 +256,259 @@
 st;%0A
-%0Aimport android.content.Context;%0Aimport android.util.Log;%0A
+import java.util.Collection;%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0Aimport android.content.Context;%0Aimport android.util.Log;%0A%0A/**%0A * Fridge class stores a set of ingredients, loads/saves%0A * from a file. Duplicate ingredients are ignored.%0A */
 %0Apub
@@ -535,24 +535,18 @@
 private 
-ArrayLis
+Se
 t%3CString
@@ -601,25 +601,31 @@
 s = new 
-ArrayList
+HashSet%3CString%3E
 ();%0A%09%7D%0A%09
@@ -633,20 +633,23 @@
 %09public 
-void
+boolean
  addIngr
@@ -674,24 +674,31 @@
 edient) %7B%0A%09%09
+return 
 ingredients.
@@ -753,17 +753,25 @@
 ent(
+Str
 in
-t index
+g ingredient
 ) %7B%0A
@@ -797,11 +797,180 @@
 e(in
-dex
+gredient);%0A%09%7D%0A%09%0A%09public Collection%3CString%3E getIngredients()%0A%09%7B%0A%09%09return new ArrayList%3CString%3E(ingredients);%0A%09%7D%09%0A%0A%09public int countIngredients() %7B%0A%09%09return ingredients.size(
 );%0A%09
@@ -1565,24 +1565,18 @@
 ents = (
-ArrayLis
+Se
 t%3CString

Make Fridge class more like a set.