-
-
Save anonymous/008fc9d9d4bde1c88143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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