diff options
author | beanplebs <benalmstead@gmail.com> | 2025-02-15 15:43:20 -0500 |
---|---|---|
committer | beanplebs <benalmstead@gmail.com> | 2025-02-15 15:43:20 -0500 |
commit | 27550aa067f5f763356c869c79f6ab4361ae0008 (patch) | |
tree | 4cbf2177865b807b73f6fd79d9dd8739b69097ae | |
parent | 02263b06819dba25e2e13b3b5e42554044db09c2 (diff) | |
download | JellySolutions-27550aa067f5f763356c869c79f6ab4361ae0008.tar.gz JellySolutions-27550aa067f5f763356c869c79f6ab4361ae0008.tar.bz2 JellySolutions-27550aa067f5f763356c869c79f6ab4361ae0008.zip |
Cupboard CRUD methods
-rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/Cupboard.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/Cupboard.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/Cupboard.java index 6b200d3..a11e7ab 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/Cupboard.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/Cupboard.java @@ -4,4 +4,48 @@ import java.util.ArrayList; public class Cupboard { ArrayList<Need> needs; + + public Cupboard() { + needs = new ArrayList<Need>(); + } + + public void addNeed(Need need) { + needs.add(need); + } + + public void createNeed(String name, double max, Need.GoalType type) { + Need need = new Need(name, 0, max, type); + addNeed(need); + } + + 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); + } + } |