Now with a 22-recipe survey_dataset.xml.
Unit test shows an example of checking that Honey cake contains gluten, eggs and spice but not red meat, shellfish or poultry.
This commit is contained in:
@@ -4,9 +4,30 @@ 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}
|
||||
|
||||
private String item;
|
||||
|
||||
public String getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public boolean isType(TYPE type) {
|
||||
switch (type) {
|
||||
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 SPICE :
|
||||
return item.endsWith("cinnamon") || item.endsWith("nutmeg") || item.endsWith("cloves");
|
||||
case SUGAR :
|
||||
return item.endsWith("sugar");
|
||||
default : //unknown ingredient, e.g. coffee, bananas, honey
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
33
src/net/woodyfolsom/cs6601/p2/IngredientDivision.java
Normal file
33
src/net/woodyfolsom/cs6601/p2/IngredientDivision.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package net.woodyfolsom.cs6601.p2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamImplicit;
|
||||
|
||||
@XStreamAlias("ing-div")
|
||||
public class IngredientDivision {
|
||||
@XStreamImplicit
|
||||
private List<Ingredient> ingredients;
|
||||
private String title;
|
||||