Work in progress.

Able to read short survey, recipe book but crashing in Bayes Net code.
This commit is contained in:
Woody Folsom
2012-03-11 21:25:04 -04:00
parent 3046f68681
commit bb94356ec1
11 changed files with 999 additions and 37 deletions

View File

@@ -4,7 +4,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
@XStreamAlias("ing")
public class Ingredient {
public enum TYPE { ALCOHOL, DAIRY, EGGS, FISH, GLUTEN, GRAIN, NUTS, PORK, POULTRY, RED_MEAT, SHELLFISH, SPICE, SUGAR}
public enum TYPE { ALCOHOL, BEEF, DAIRY, EGGS, FISH, GLUTEN, GRAIN, NUTS, PORK, POULTRY, POTATO, SHELLFISH, SPICE, SUGAR, TOMATO}
private String item;
@@ -14,20 +14,31 @@ public class Ingredient {
public boolean isType(TYPE type) {
switch (type) {
case BEEF :
return item.contains("beef");
case DAIRY :
return item.contains("margarine");
case EGGS :
return item.equals("egg") || item.equals("eggs");
case GLUTEN :
return item.contains("flour");
case RED_MEAT :
return item.contains("beef");
case PORK :
return item.contains("pork");
case POTATO :
return item.contains("potato");
case SPICE :
return item.endsWith("cinnamon") || item.endsWith("nutmeg") || item.endsWith("cloves");
case SUGAR :
return item.endsWith("sugar");
case TOMATO :
return item.contains("tomato");
default : //unknown ingredient, e.g. coffee, bananas, honey
return false;
}
}
public Object readResolve() {
item = item.toLowerCase();
return this;
}
}