I really need help with the code of a Circular Linked List...it seems I suck at writing code. It has errors gallore and I would appreciate any help I could get. Unfortunately it needs to be done by midnight tonight so...PLEASE HELP ME!!!!!!! Here is what I got so far. If you can help me in time I will forever be your best friend!
import java.util.Scanner; public interface CircularListADT<T> { public int count; public Node top; public void insertNode(T value){ Node newNode = new Node(); top.setNext(newNode); top = newNode; } public boolean deleteNode(T value){ top = top.getNext(); } public Node getCurrentNode(){ return top; } public Node forward(){ Node<T> current = top; current = top.getNext(); return current; } /** * Move the current node reference backward to its previous node, * and return the updated current node reference * @return */ public Node backword(){ } /** * Find if the list hold a node with its element being * the passed value * @param value * @return null if no such node exists, or the node * reference that points to the object with the same element */ public Node search(T value){ } public int size(){ int count = 0; Node<T> t = top; while(t!=top){ count++; t=t.getNext(); } if(t.getNext()==top){ break; } return count; } public String toString(){ String result = ""; Node<T> current = top; while (current != null) { result = result + (current.getElement()).toString() + "\n"; current = current.getNext(); } return result; } } public class Node<T> { private Node<T> next; private T element; public Node() { next = null; element = null; } public Node(T elem) { next = null; element = elem; } public Node<T> getNext() { return next; } public void setNext(Node<T> node) { next = node; } public T getElement() { return element; } public void setElement(T elem) { element = elem; } public String toString(){ return ""+element + " with the next node of "+next.getElement(); } } public class CircularListDriver { public static void main(String[]args){ String operation = "none"; Scanner scan = new Scanner(System.in); System.out.println("Select an option: "); operation = scan.next(); if(operation.equalsIgnoreCase("insert")) insertNode(); else if(operation.equalsIgnoreCase("delete")) deleteNode(); else if(operation.equalsIgnoreCase("current node")) getCurrentNode(); else if(operation.equalsIgnoreCase("forward")) forward(); else if(operation.equalsIgnoreCase("backword")) backward(); else if(operation.equalsIgnoreCase("search")) search(); else if(operation.equalsIgnoreCase("size")) size(); } }