Skip to content

Instantly share code, notes, and snippets.

Created October 30, 2014 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/008fc9d9d4bde1c88143 to your computer and use it in GitHub Desktop.
Save anonymous/008fc9d9d4bde1c88143 to your computer and use it in GitHub Desktop.
package testers;
import lab4.Recipe;
public class IngredientTester {
private double value = 0.0;
private String unit = "";
public IngredientTester(double butterMain, String nameOfIngredient) {
// TODO Auto-generated constructor stub
}
public void Ingredient(double ingredient, String nameOfIngredient) {
Recipe recipe = new Recipe();
value = recipe.getIngredients(nameOfIngredient, 0.0);
}
public void setValue(double temp) {
value = temp;
}
public void setUnit(String temp) {
unit = temp;
}
public String returnIngredientAmountAndUnit() {
return value + " " + unit;
}
public void convertUnit() {
if (unit.equals("pinch")) {
if (value > 4) {
double temp = Math.round((value / 8.0) * 100.0) / 100.0;
setValue(temp);
setUnit("teaspoon");
}
} else if (unit.equals("teaspoon")) {
if (value > 1.5) {
double temp = Math.round((value / 3.0) * 100.0) / 100.0;
setValue(temp);
setUnit("tablespoon");
}
} else if (unit.equals("teaspoon")) {
if (value > 8) {
double temp = Math.round((value / 16.0) * 100.0) / 100.0;
setValue(temp);
setUnit("cups");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment