I am working on an assignment and I need a bit of help. I am using a double linked list to find roots of polynomials, the list has a trailer node only. I can't seem to get it to create a list. I figure I am just missing something small or not understanding a small part.
public class Polynomial
{
private Node top;
public Polynomial()
{
Node trailer = new Node("","",null, null);
top.setNext(trailer);
}
}
class Node{
private double coef;
private int degree;
private Node next;
private Node prev;
public Node(double coef, int degree, Node newNext, Node newPrev)
{
this.coef = coef;
this.degree = degree;
next = newNext;
prev = newPrev;
}
public void setNext(Node newNext)
{
next = newNext;
}
}//there is more code in the node class, but is not being used yet
//this is the main method that creates the polynomial class(which is the linked list)
public static void main(String[] args)
{
Polynomial poly= new Polynomial();
poly.set(2.0, 3);
}
the problem seem to happen when I try to create the new Polynomial, " Polynomial poly= new Polynomial();". I get the error
Polynomial.java:8: cannot find symbol
symbol : constructor Node(java.lang.String,java.lang.String,<nulltype>,<nulltype>)
location: class Node
Node trailer = new Node("","",null, null);
I know I'm passing 2 strings, I'm not sure how to make this Node empty, since it stores a double and an int.