Work in progress.

This commit is contained in:
Woody Folsom
2012-03-12 14:33:41 -04:00
parent c1f68f6f5c
commit 16a97ba39a
15 changed files with 1424 additions and 753 deletions

View File

@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
@@ -16,6 +17,32 @@ public class Survey {
@XStreamImplicit(itemFieldName="diner")
private List<Diner> diners = new ArrayList<Diner>();
public double getAverageRating(int recipeIndex) {
double total = 0.0;
for (Diner diner : diners) {
total += diner.getRating(recipeIndex);
}
return total/diners.size();
}
public boolean isDiner(String category) {
for (int i = 0; i < diners.size(); i++) {
if (isCategory(i,category)) {
return true;
}
}
return false;
}
public boolean isCategory(int dinerIndex, String category) {
for (Entry<Integer,String> entry : categories.entrySet()) {
if (entry.getValue().equals(category)) {
return diners.get(dinerIndex).isCategory(entry.getKey());
}
}
return false;
}
public Diner getDiner(int dinerIndex) {
return diners.get(dinerIndex);
}