Skip to content
Snippets Groups Projects
Commit d3bcaa29 authored by Tucker Gary Siegel's avatar Tucker Gary Siegel
Browse files

add product to the common package since it will be shared

parent 35afb5f7
No related branches found
Tags 0.13.0
No related merge requests found
package edu.umd.dawn.common.enums;
import edu.umd.dawn.common.exceptions.DawnException;
import edu.umd.dawn.common.exceptions.BaseExceptions;
import java.util.Map;
public enum Product {
CORN(50.0);
public final double baseTemp;
private Product(double baseTemp) {
this.baseTemp = baseTemp;
}
public Map<String, Double> getStages(String mode, int value) {
if (!this.equals(CORN)) {
throw new DawnException(BaseExceptions.PRODUCT_UNSUPPORTED);
}
double harvestVal;
if (mode.equals("rm")) {
harvestVal = ((((double) value) - 95.0) * 22.0) + 2375.0;
} else {
harvestVal = (double) value;
}
return Map.of(
"emergence", harvestVal * 0.07,
"3LeafCollar", harvestVal * 0.13,
"6LeafCollar", harvestVal * 0.2,
"silk", harvestVal * 0.545,
"milk", harvestVal * 0.725,
"harvest", harvestVal);
}
}
......@@ -35,4 +35,7 @@ public class BaseExceptions {
public static DawnExceptionParameters INVALID_OFFSET(int offset) {
return new DawnExceptionParameters(400, "BAD_REQUEST", String.format("offset of %d is invalid", offset), "");
}
public static final DawnExceptionParameters PRODUCT_UNSUPPORTED = new DawnExceptionParameters(
400, "BAD_REQUEST", "This operation is unsupported for provided product", "");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment