-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomerStack.java
More file actions
39 lines (33 loc) · 847 Bytes
/
CustomerStack.java
File metadata and controls
39 lines (33 loc) · 847 Bytes
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
public class CustomerStack {
Customer head;
Customer current;
Customer tail;
public CustomerStack() {
head = null;
current = null;
}
public void push(Customer newPerson) {
if (head == null) {
head = new Customer(newPerson, head);
tail = head;
} else {
head = new Customer(newPerson, head);
}
}
public Customer pop() {
Customer current;
current = head;
if (current != null)
head = head.getCustomerLink();
return current;
}
public int getSize() {
int size = 0;
Customer current = head;
while (current != null) {
size++;
current = current.getCustomerLink();
}
return size;
}
}