blob: de1695a2b2e8b7e1a3e09df27c8c1dc0f76d6e2d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package com.ufund.api.ufundapi.model;
import com.ufund.api.ufundapi.persistence.CupboardDAO;
import com.ufund.api.ufundapi.persistence.CupboardFileDao;
import java.io.IOException;
public class Cupboard {
CupboardDAO dao = new CupboardFileDao();
public void createNeed(Need need) throws IOException {
int id = dao.getNeeds().length;
dao.createNeed(need);
}
// public void updateID(int id) throws IOException {
// for (int i = 0; i < getNeeds().length; i++) {
// needs.get(i).setID(i);
// }
// }
public Need[] findNeeds(String name) throws IOException {
return dao.findNeeds(name);
}
public void updateNeed(Need need) throws IOException {
dao.updateNeed(need);
}
public void removeNeed(int id) throws IOException {
dao.deleteNeed(id);
}
public void removeNeed(String name) throws IOException {
for (Need need : getNeeds()) {
if (need.getName().equals(name)) {
dao.deleteNeed(need.getID());
return;
}
}
}
public Need[] getNeeds() throws IOException {
return dao.getNeeds();
}
public Need getNeed(int id) throws IOException {
return dao.getNeed(id);
}
}
|