-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSystem.pde
More file actions
60 lines (58 loc) · 1.19 KB
/
System.pde
File metadata and controls
60 lines (58 loc) · 1.19 KB
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
52
53
54
55
56
57
58
59
60
class System implements InventorySkeleton
{
void System()
{
}
void onSearch(String s)
{
uic.setCreateProductVisible(false);
ArrayList<Product> results = db.find(s);
uic.showSearchResults(results); //find on database and send results to UIControl
if(!checkPresent(results, s))
{
uic.setCreateProductVisible(true);
}
}
private boolean checkPresent(ArrayList<Product> al, String s)
{
for(Product p : al)
{
if(p.getName().toLowerCase().equals(s.toLowerCase()))
{
return true;
}
}
return false;
}
void onResultSelect(int index)
{
uic.showProduct(db.get(index));
uic.setCreateProductVisible(false);
}
void onCreate(String name)
{
println(name);
Product product = new Product(name, "", "", 0, 0, "");
uic.showProduct(product);
db.add(product);
uic.toggleModify();
}
void onModify(Product p)
{
db.delete(p);
db.add(p);
uic.toggleModify();
}
void onDelete(Product p)
{
db.delete(p);
}
}
interface InventorySkeleton
{
void onSearch(String s);
void onResultSelect(int index);
void onCreate(String s);
void onModify(Product p);
void onDelete(Product p);
}