aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java
diff options
context:
space:
mode:
authorTyler Ferrari <69283684+Sowgro@users.noreply.github.com>2025-04-01 02:17:25 -0400
committerGitHub <noreply@github.com>2025-04-01 02:17:25 -0400
commit233fe120d2a9b30e0150401ebdfeb946dc9c2c07 (patch)
tree98583e1b1d21d1a0cc57e8ff3489fbbf758eccff /ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java
parentc6bbb29f42eaea7d0c8aebdb7b95be0287cbf4f9 (diff)
parent0e9c0803e35a23ef2e873dc7ebf224a49a92f207 (diff)
downloadJellySolutions-233fe120d2a9b30e0150401ebdfeb946dc9c2c07.tar.gz
JellySolutions-233fe120d2a9b30e0150401ebdfeb946dc9c2c07.tar.bz2
JellySolutions-233fe120d2a9b30e0150401ebdfeb946dc9c2c07.zip
Merge pull request #22 from RIT-SWEN-261-02/css
Merge css into main
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java')
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java
index aaa8cb8..993e7c1 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java
@@ -25,16 +25,22 @@ public class CupboardService {
* Creates a new Need
*
* @param name The name of the need to create
+ * @param image The image representation of the need to create
+ * @param location The location of the new need
* @param maxGoal The max goal of the new need
* @param goalType The goal type of the new need
+ * @param urgent The urgency of the new need
+ * @param description The description of the new need
* @return The need that was created
* @throws IOException Thrown if there was any issue saving the data
* @throws DuplicateKeyException If there already exists a need with the same name
*/
- public Need createNeed(String name, double maxGoal, Need.GoalType goalType) throws IOException, DuplicateKeyException {
+ public Need createNeed(String name, String image, String location, double maxGoal, Need.GoalType goalType, boolean urgent, String description) throws IOException, DuplicateKeyException {
if (maxGoal <= 0) {
throw new IllegalArgumentException("Max Goal must be greater than zero");
+ } else if (goalType.equals(Need.GoalType.PHYSICAL) && maxGoal % 1 != 0) {
+ throw new IllegalArgumentException("Cannot have non whole number value for physical goal");
}
for (Need searchNeed : cupboardDAO.getNeeds()) {
@@ -43,7 +49,7 @@ public class CupboardService {
}
}
- Need need = new Need(name, goalType, maxGoal);
+ Need need = new Need(name, image, location, maxGoal, goalType, urgent, description);
return cupboardDAO.addNeed(need);
}
@@ -95,6 +101,8 @@ public class CupboardService {
}
if (need.getMaxGoal() <= 0) {
throw new IllegalArgumentException("Goal must be greater than 0");
+ } else if (need.getType().equals(Need.GoalType.PHYSICAL) && need.getMaxGoal() % 1 != 0) {
+ throw new IllegalArgumentException("Cannot have non whole number value for physical goal");
}
return cupboardDAO.updateNeed(need);
}