diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2025-02-16 11:05:59 -0500 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2025-02-16 11:05:59 -0500 |
commit | be155cb28c8c5662a6dd9ce9268b06869087b4a0 (patch) | |
tree | 987aa467d7a298931bfe2ea363c8f8d2b186f5ca /ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java | |
parent | a2dbadb51d61cb8b16965ed895144050c1dc3c9a (diff) | |
download | JellySolutions-be155cb28c8c5662a6dd9ce9268b06869087b4a0.tar.gz JellySolutions-be155cb28c8c5662a6dd9ce9268b06869087b4a0.tar.bz2 JellySolutions-be155cb28c8c5662a6dd9ce9268b06869087b4a0.zip |
Organize into sub-packages
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java')
-rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java new file mode 100644 index 0000000..fedf04e --- /dev/null +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java @@ -0,0 +1,58 @@ +package com.ufund.api.ufundapi.model; + +import java.util.ArrayList; + +public class Cupboard { + ArrayList<Need> needs; + + public Cupboard() { + needs = new ArrayList<>(); + } + + public void addNeed(Need need) { + needs.add(need); + } + + public void createNeed(String name, double max, Need.GoalType type) { + int id = needs.size(); + Need need = new Need(name, id, max, type); + addNeed(need); + } + + public void updateID(int id) { + for (int i = 0; i < needs.size(); i++) { + needs.get(i).setID(i); + } + } + + public void removeNeed(Need need) { + needs.remove(need); + } + + public void updateNeed(Need need) { + for (int i = 0; i < needs.size(); i++) { + if (needs.get(i).getID() == need.getID()) { + needs.set(i, need); + return; + } + } + } + + public void removeNeed(String name) { + for (int i = 0; i < needs.size(); i++) { + if (needs.get(i).getName().equals(name)) { + needs.remove(i); + return; + } + } + } + + public Need[] getNeeds() { + return needs.toArray(new Need[0]); + } + + public Need getNeed(int index) { + return needs.get(index); + } + +} |