diff --git a/src/main/java/edu/umd/dawn/common/enums/Product.java b/src/main/java/edu/umd/dawn/common/enums/Product.java new file mode 100644 index 0000000000000000000000000000000000000000..94083a961c8a3ce69136bd44030b3a9acd21d065 --- /dev/null +++ b/src/main/java/edu/umd/dawn/common/enums/Product.java @@ -0,0 +1,36 @@ +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); + } +} diff --git a/src/main/java/edu/umd/dawn/common/exceptions/BaseExceptions.java b/src/main/java/edu/umd/dawn/common/exceptions/BaseExceptions.java index c9b777deace7f8fcd0031dcacb47075e60bc9174..141384bafb6c50fa0f192793567177feac2c2cc8 100644 --- a/src/main/java/edu/umd/dawn/common/exceptions/BaseExceptions.java +++ b/src/main/java/edu/umd/dawn/common/exceptions/BaseExceptions.java @@ -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", ""); }