First is my node class, which compiles fine and I've used for different programs now. I have done a QueueArray with success but not a QueueLinked List.
When i try to compile my Queue LL, i constantly keep getting the error that constructor Node in class Node cannot be applied to given types; Node newNode = new Node(a);
However, no matter what I put there, I keep getting errors and just have no idea what the next step is to make my enqueue work. Any tips?
public class Node{
private Node next;
private String name;
private int ssn;
private int key;
public Node(String name, int ssn){
this.name = name;
this.ssn = ssn;
}
public void setNext(Node n){
this.next = n;
}
public int getSSN(){
return this.ssn;
}
public int getKey(){
return ssn%10000;
}
public String getName(){
return name;
}
public Node getNext(){
return this.next;
}
public void setSSN(int ssn){
this.ssn= ssn;
}
}
public class QueueLL{
private Node first;
private Node last;
private int n;
private Node queue;
public QueueLL(){
first = null;
last = null;
n = 0;
}
public boolean isEmpty(){
return first == null;
}
public Node front(){
return first;
}
public void enqueue(Node a){
Node newNode = new Node(a);
if (first == null){
first = a;
last = first;
}
else{
last = a.getNext();
last = a;
}
}
public Node dequeue(){
if (first == null){
return null;
}
else{
Node temp = first;
first = first.getNext();
return temp;
}
}
// printQueue method for QueueLL
public void printQueue() {
System.out.println(n);
Node temp = first;
while (temp != null) {
System.out.println(temp.getKey());
temp = temp.getNext();
}
}
}
Node. Why would you expect it to compile?"I keep getting errors and just have no idea what the next step is to make my enqueue work. Any tips?"-- consider telling and showing all error messages. They're kind of important.QueueLL.java:22: error: constructor Node in class Node cannot be applied to given types; Node newNode = new Node(a); ^ required: String,int found: Node reason: actual and formal argument lists differ in length 1 error