switched to switch case
This commit is contained in:
parent
37fd3b18be
commit
3ca526e0f1
1 changed files with 30 additions and 26 deletions
|
|
@ -72,35 +72,39 @@ public class FormalIngredient extends RecipeIngredient implements Scalable<Forma
|
||||||
Unit currentUnit = unit.get();
|
Unit currentUnit = unit.get();
|
||||||
double baseAmount = amount * currentUnit.conversionFactor;
|
double baseAmount = amount * currentUnit.conversionFactor;
|
||||||
|
|
||||||
if(currentUnit == Unit.GRAMME){
|
switch (currentUnit){
|
||||||
if(baseAmount >= Unit.TONNE.conversionFactor){
|
case GRAMME -> {
|
||||||
return baseAmount /Unit.TONNE.conversionFactor + Unit.TONNE.suffix;
|
if(baseAmount >= Unit.TONNE.conversionFactor){
|
||||||
|
return baseAmount /Unit.TONNE.conversionFactor + Unit.TONNE.suffix;
|
||||||
|
}if(baseAmount >=Unit.KILOGRAMME.conversionFactor) {
|
||||||
|
return baseAmount / Unit.KILOGRAMME.conversionFactor + Unit.KILOGRAMME.suffix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(baseAmount >=Unit.KILOGRAMME.conversionFactor) {
|
|
||||||
return baseAmount / Unit.KILOGRAMME.conversionFactor + Unit.KILOGRAMME.suffix;
|
case MILLILITRE -> {
|
||||||
|
if (baseAmount >= Unit.LITRE.conversionFactor) {
|
||||||
|
return baseAmount /Unit.LITRE.conversionFactor + Unit.LITRE.suffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case TABLESPOON -> {
|
||||||
|
if(amount>=tbspToPoundConvert){
|
||||||
|
return amount/tbspToPoundConvert + Unit.POUND.suffix;
|
||||||
|
}
|
||||||
|
if(amount>=tbspToCupConvert){
|
||||||
|
return amount /tbspToCupConvert + Unit.CUP.suffix;
|
||||||
|
}
|
||||||
|
if(amount>=tbspToOunceConvert){
|
||||||
|
return amount /tbspToOunceConvert + Unit.OUNCE.suffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case OUNCE -> {
|
||||||
|
if (baseAmount >= OunceToPoundConvert) {
|
||||||
|
return amount / OunceToPoundConvert + Unit.POUND.suffix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentUnit == Unit.MILLILITRE && baseAmount >= Unit.LITRE.conversionFactor) {
|
|
||||||
return baseAmount /Unit.LITRE.conversionFactor + Unit.LITRE.suffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(currentUnit == Unit.TABLESPOON){
|
|
||||||
if(amount>=tbspToPoundConvert){
|
|
||||||
return amount/tbspToPoundConvert + Unit.POUND.suffix;
|
|
||||||
}
|
|
||||||
if(amount>=tbspToCupConvert){
|
|
||||||
return amount /tbspToCupConvert + Unit.CUP.suffix;
|
|
||||||
}
|
|
||||||
if(amount>=tbspToOunceConvert){
|
|
||||||
return amount /tbspToOunceConvert + Unit.OUNCE.suffix;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (currentUnit == Unit.OUNCE && baseAmount >= OunceToPoundConvert) {
|
|
||||||
return amount / OunceToPoundConvert + Unit.POUND.suffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
return amount + currentUnit.suffix;
|
return amount + currentUnit.suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue