Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Plz, use java netbeans 8.2 or 8.1 thank u Create a new Java Application to manag

ID: 3798697 • Letter: P

Question

Plz, use java netbeans 8.2 or 8.1

thank u

Create a new Java Application to manage Linked Lists: (Note: Do not use java.util.LinkedList)

a) Create a Clock class

1. Add hour, minute, and second as attributes

2. Add a constructor and a toString() method

3. Implement the Comparable interface, and add a CompareTo() method

4. Add methods to get and set all attributes.

b) Add to MyLinkedList class the following methods:

1. Insert a node at the front of the list

2. Insert a Node in place, assuming that the list is ordered in ascending order.

3. Delete node in front

4. Delete last node

5. Method to return the size of the list

6. Method to find the node with the minimum value in the list – getMinimum()

c) Create a Test3 class to do the following in the main method:

1. Create a new List (call it clockList) of type MyLinkedList

2. Insert five Clock objects numbers to the list (not ordered).

3. Display all the clocks in the List

4. Sort the List and display it in both ascending and descending

5. Display the largest element in the list

6. Display the smallest element in the list

7. Display the size of the list

8. Search for a particular clock in the List by printing true if found or false.

9. Delete a clock from the front of the list

10. Delete a clock from the back of the list

11. Order the list in ascending order

12. Insert a new clock elements to its appropriate position in the List and display it

d) Create a new Node class, call it Node2 with Data, linkForward, and linkBackward

e) Create a new class MyDoublyLinkedList.

1. Do the addToEnd() method and addToFront() methods

2. Do the displayForward() and displayBackward() methods

f) Create a Test4 class to test your doubly linked list of Integer objects.

1. Create an object of type MyDoublyLinkedList

2. Add 5 Integer objects to your doubly linked list (add some to the back and some to the front)

3. Display your list by going both forward and backward.

Explanation / Answer

class Node2 {

   private int data;

   private Node2 linkForward;

   private Node2 linkBackward;

   public int getData() {

       return data;

   }

   public void setData(int data) {

       this.data = data;

   }

   public Node2(int data) {

       super();

       this.data = data;

   }

   public Node2 getLinkForward() {

       return linkForward;

   }

   public void setLinkForward(Node2 linkForward) {

       this.linkForward = linkForward;

   }

   public Node2 getLinkBackward() {

       return linkBackward;

   }

   public void setLinkBackward(Node2 linkBackward) {

       this.linkBackward = linkBackward;

   }

}

public class MyDoublyLinkedList {

   Node2 head, end;

   public void addToFront(int data) {

       if (head == null) {

           head = new Node2(data);

           end = head;

       } else {

           Node2 temp = new Node2(data);

           temp.setLinkForward(head);

           head.setLinkBackward(temp);

           head =temp;

       }

   }

   public void addToEnd(int data) {

       if (end == null) {

           head = new Node2(data);

           end = head;

       }

       else{

           Node2 temp = new Node2(data);

           temp.setLinkBackward(end);

           end.setLinkForward(temp);

           end=temp;

       }

      

   }

  

   public void displayForward(){

       Node2 temp=head;

       while(temp!=null)

       {

           System.out.print(temp.getData()+" -> ");

           temp=temp.getLinkForward();

       }

       System.out.println();

   }

   public void displayBackward(){

       Node2 temp=end;

       while(temp!=null)

       {

           System.out.print(temp.getData()+" -> ");

           temp=temp.getLinkBackward();

       }

       System.out.println();

   }

  

   // testing

  

   public static void main(String[] args) {

       MyDoublyLinkedList myList=new MyDoublyLinkedList();

       myList.addToFront(10);//10->

       myList.addToFront(20);//20->10->

       myList.addToEnd(30);//20->10->30

       // you can add more

      

       myList.displayForward();

       myList.displayBackward();

      

   }

  

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote