From d3bcaa29aebdbf917eddc49042ae864910b1af7b Mon Sep 17 00:00:00 2001
From: Tucker Siegel <tgsiegel@terpmail.umd.edu>
Date: Sun, 16 Apr 2023 17:27:16 -0400
Subject: [PATCH] add product to the common package since it will be shared

---
 .../edu/umd/dawn/common/enums/Product.java    | 36 +++++++++++++++++++
 .../common/exceptions/BaseExceptions.java     |  3 ++
 2 files changed, 39 insertions(+)
 create mode 100644 src/main/java/edu/umd/dawn/common/enums/Product.java

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 0000000..94083a9
--- /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 c9b777d..141384b 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", "");
 }
-- 
GitLab