Question: lab 4 code: class AddressNode { public String name, cellPhone, email, degree; AddressNode next, previous; public AddressNode ( String name, String cellPhone, String email, String

"lab 4 code:
class AddressNode { public String name, cellPhone, email, degree; AddressNode next, previous; public AddressNode(String name, String cellPhone, String email, String degree){ this.name = name; this.cellPhone = cellPhone; this.email = email; this.degree = degree; this.next = null; this.previous = null; }} class AddressBook { private AddressNode head, tail; public AddressBook(){ head = null; tail = null; } public void addAtHead(String name, String phone, String email, String degree){ AddressNode newNode = new AddressNode(name, phone, email, degree); if(head == null){ head = tail = newNode; } else { newNode.next = head; head.previous = newNode; head = newNode; }} public void addAtTail(String name, String phone, String email, String degree){ AddressNode newNode = new AddressNode(name, phone, email, degree); if(head == null){ head = tail = newNode; } else { newNode.previous = tail; tail.next = newNode; tail = newNode; }} public void removeFromHead(){ if(head == null){ System.out.println(""Empty address book!""); return; } if(head == tail) head = tail = null; else { head = head.next; head.previous = null; }} public void removeFromTail(){ if(head == null){ System.out.println(""Empty address book!""); return; } if(head == tail) head = tail = null; else { tail = tail.previous; tail.next = null; }} public void displayList(){ AddressNode temp = head; if(head == null){ System.out.println(""Empty address book!""); return; } while(temp != null){ System.out.println(""Name: ""+temp.name+"", Phone: ""+temp.cellPhone+"", Email: ""+temp.email+"", Degree: ""+temp.degree); temp = temp.next; }}} Test Class: public class TestAddressBook { public static void main(String[] args){ AddressBook adBook = new AddressBook(); adBook.addAtHead(""Fahad"",""0568799425"",""Fahad@alfaisal.edu"", ""MED""); adBook.addAtHead(""Faisal"",""0557812669"",""Faisal@alfaisal.edu"", ""MED""); System.out.println(""After adding two nodes(Fahad & Faisal) at the head:""); adBook.displayList(); System.out.println(""==================================================================""); adBook.addAtTail(""Saud"",""055427758"",""Saud@alfaisal.edu"", ""SE""); adBook.addAtTail(""Ahmed"",""057895246"",""Ahmed@alfaisal.edu"", ""SE""); System.out.println(""
After ad7758ding two nodes(Saud & Ahmed) at the tail:""); adBook.displayList(); System.out.println(""==================================================================""); adBook.removeFromHead(); System.out.println(""
After removing one node from the head:""); adBook.displayList(); System.out.println(""==================================================================""); adBook.removeFromTail(); System.out.println(""
After removing one node from the tail:""); adBook.displayList(); System.out.println(""== XR16================================================================""); }}
Based on the doubly linked list code created during lab 4. Create a doubly linked list based queue that does each of the following: 1. Create an empty queue. 2. Add a String to the queue 3. Print the content of the queue. 4. Repeat steps 2 and 3 three times and observe the output check if your implementation is correct. Paste the screen shot of your program and output here:"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!