-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerson.java
More file actions
45 lines (36 loc) · 742 Bytes
/
Person.java
File metadata and controls
45 lines (36 loc) · 742 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
40
41
42
43
44
45
public class Person{
private int items;
private Person next, prev, end;
private static int queueSize = 0;
public Person(int items){
this.items = items;
this.next = null;
this.prev = null;
}
public Person getNext(){
return next;
}
public Person getPrev(){
return prev;
}
public int getItems(){
return items;
}
public int getQueueSize(){
return queueSize;
}
public void addPerson(Person newPerson){
if(this.next == null){
this.next = newPerson;
newPerson.prev = this;
queueSize++;
System.out.println(newPerson.getItems());
} else {
this.next.addPerson(newPerson);
}
}
public void servePerson(){
this.next = this.next.getNext();
queueSize--;
}
}