-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
70 lines (56 loc) · 1.33 KB
/
Node.java
File metadata and controls
70 lines (56 loc) · 1.33 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
61
62
63
64
65
66
67
68
69
70
/**
A Node class that holds references to the data, next node, and count/stock of the item.
@author Hasti Abbasi Kenarsari
*/
public class Node<T> {
// Entry in list
private T data;
// The link to the next node
private Node<T> next;
// The quantity of the item in stock
private int count;
// constructor
public Node(T dataPortion) {
this(dataPortion, null);
}
public Node(T dataPortion, Node<T> nextNode) {
data = dataPortion;
next = nextNode;
count = 0;
}
public Node(T dataPortion, Node<T> nextNode, int stock) {
data = dataPortion;
next = nextNode;
count = stock;
}
public T getData() {
return data;
}
public void setData(T newData) {
data = newData;
}
public Node<T> getNextNode() {
return next;
}
public void setNextNode(Node<T> nextNode) {
next = nextNode;
}
public int getCount() {
return count;
}
public void setCount(int stock) {
count = stock;
}
public void incrementCount(int amount) {
count += amount;
}
public void decrementCount(int amount) {
count -= amount;
}
public void clearCount() {
count = 0;
}
public boolean hasCount() {
return count > 0;
}
}