-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItem.java
77 lines (63 loc) · 1.64 KB
/
Item.java
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
Item class
*/
import java.util.ArrayList;
public class Item{
public static ArrayList<Item> items = new ArrayList<Item>();
private String ID;
private String itemName;
private int packAmount;
public static enum STATUS{WAREHOUSE, DELIVERED, STORED};
private STATUS itemStatus = STATUS.WAREHOUSE;
public Item(){}
public String getID(){
return ID;
}
public void setID(String i){
ID = i;
}
public String getItemName(){
return itemName;
}
public void setItemName(String name){
itemName = name;
}
public STATUS getItemStatus(){
return itemStatus;
}
public void setItemStatus(STATUS itemStat){
itemStatus = itemStat;
}
//generate randomly simulated item
public static Item randomItem(){
Item ii = new Item();
ii.setItemName("Item #" + (int)Math.round(Math.random()*10000));
ii.setID(randomID());
ii.setItemStatus(STATUS.WAREHOUSE);
return ii;
}
//generate blank item
public static Item blankItem(){
Item ii = new Item();
ii.setItemName("");
ii.setID(randomID());
ii.setItemStatus(STATUS.WAREHOUSE);
return ii;
}
//generate random ID for item
//converts string into char array and picks 10 from that.
public static String randomID(){
String charPool = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
char[] charArr = new char[charPool.length()];
for (int i = 0; i < charPool.length(); i++) {
charArr[i] = charPool.charAt(i);
}
int size = 10;
String newID = "";
for(int i = 0; i < size; i++){
newID+= charArr[Math.round((int)(Math.random()*charArr.length))];
}
System.out.println(newID);
return newID;
}
}