/
FCITqueue.java
60 lines (53 loc) · 1.2 KB
/
FCITqueue.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
class FCITqueue {
private FCITstudent front;
private FCITstudent back;
private int noOfStudentsInQueue;
public boolean isEmpty() {
return this.getNoOfStudentsInQueue()==0;//return getfront() == null;
}
public void enqueue(FCITstudent student) {
FCITstudent oldback = back;
back = student;
if (isEmpty())
setfront(back);
else
oldback.setNext(back);
setNoOfStudentsInQueue(getNoOfStudentsInQueue() + 1);
}
public FCITstudent dequeue() {
FCITstudent student = getfront();
setfront(getfront().getNext());
if (isEmpty())
back = null;
setNoOfStudentsInQueue(getNoOfStudentsInQueue() - 1);
student.setNext(null);
return student;
}
/**
* @return the front
*/
public FCITstudent getfront() {
return front;
}
/**
* @param front the front to set
*/
public void setfront(FCITstudent front) {
this.front = front;
}
public FCITstudent getBack() {
return back;
}
/**
* @return the noOfStudentsInQueue
*/
public int getNoOfStudentsInQueue() {
return noOfStudentsInQueue;
}
/**
* @param noOfStudentsInQueue the noOfStudentsInQueue to set
*/
public void setNoOfStudentsInQueue(int noOfStudentsInQueue) {
this.noOfStudentsInQueue = noOfStudentsInQueue;
}
}