forked from loopccoew/Buffer_3.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DoctorList.java
114 lines (94 loc) · 1.8 KB
/
DoctorList.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package loop;
class dNode
{
Doctor Doctor ;
dNode next;
dNode prev;
//Constructor
public dNode(Doctor Doctor) {
this.Doctor = Doctor ;
next=null;
prev=null;
}
}
//Double Linked list TO insert Doctor
public class DoctorList {
dNode head,tail;
public DoctorList()
{
head=null;
tail=null;
}
public void Insert(Doctor Doctor)
{
dNode node=new dNode(Doctor);
if(head==null || tail==null)
{
head=node;
tail=node;
}
else
{
head.next=node;
node.prev=head;
head=node;
}
}
public void searchBySpeciality(String Speciality)
{
boolean b=false;
dNode temp=head;
while(temp!=null)
{
if(temp.Doctor.getSpeciality().equals(Speciality))
{
b=true;
System.out.println(temp.Doctor);
}
temp=temp.prev;
}
if(b==false)
{
System.out.println("Doctor with this speciality is not available");
}
}
public int Size()
{
dNode temp=head;
int count=0;
while(temp!=null)
{
count++;
temp=temp.prev;
}
return count;
}
public void AllDoctorInfo()
{
dNode temp=tail;
while(temp!=null)
{
System.out.println(" DoctorId : "+temp.Doctor.getId() +" DoctorName : "+temp.Doctor.getName() +" Doctor Speciality : "+temp.Doctor.getSpeciality() +" Doctor fees : "+temp.Doctor.getFees());
temp=temp.next;
}
}
public void PrintData()
{
dNode temp =head;
int count=0;
while(temp!=null)
{
count++;
System.out.println(count+": "+temp.Doctor.toString());
temp=temp.prev;
}
}
public Doctor getAtIndex(int index) {
dNode temp=head;
for(int i=0;i<index;i++)
{
temp=temp.prev;
}
return temp.Doctor;
}
}