I have 3 files and are having trouble implementing them all, can someone help me with my errors in my driver:
MY CODE:
public class Driver extends LinkList
{
public static void main(String[] args)
{
LinkList l = new LinkList();
do{
l.reader();
l.insert(word, listList);
l.print(listList);
}while(word != "stop");
do{
l.reader1();
l.remove(listList, word);
l.print(listList);
}while(rmString != "done");
l.first(listList);
l.last(listList);
l.count(listList);
}
}
MY LINKLIST CODE:
public class LinkList extends NodeClass
{
private NodeClass list;
public NodeClass getlist(){
return list;
}
public NodeClass setList(NodeClass list){
NodeClass listList = list;
return listList;
}
public LinkList(NodeClass listList){
listList = null;
}
// method
public String reader(){
String word;
System.out.println("Enter a word and enter the word stop when you are done: ");
Scanner inputDevice = new Scanner(System.in);
word = inputDevice.nextLine();
return word;
}
// next method
public void insert(String word, NodeClass listList){
NodeClass temp = new NodeClass(size, word, null);
if (listList == null){
listList = temp;
}else if (listList.getWord().compareTo(temp.getWord()) > 0){
temp.setNext(listList);
listList = temp;
}else{
NodeClass prev = null;
NodeClass curr = listList;
while(curr.getNext() != null && curr.getWord().compareTo(temp.getWord()) < 0){
prev = curr;
curr = curr.getNext();//moves the pointer
} prev.setNext(temp);
temp.setNext(curr);
}
}
// next method
public void print(NodeClass listList){
NodeClass curr;
curr = listList;
while (curr.getNext() != null){
System.out.println(curr.getWord()+" the size " + curr.getSize());
curr = curr.getNext();
}
}
public String reader1(){
String rmString;
System.out.println("Now type in a string of the node that you would like to remove, enter done when you are finishing removing strings: ");
Scanner inputDevice = new Scanner(System.in);
rmString = inputDevice.nextLine();
return rmString;
}
//next method
public void remove(NodeClass listList, String word, String rmString){
NodeClass prev, front, curr;
front=listList;
reader1();
if (front== null){
System.out.print("The list is empty.");
return;
} if (front.getWord() == rmString){
front= front.getNext();
}else{ prev= null;
curr=front;
while (curr!= null){
if (curr.getWord()==rmString){
prev.setNext(curr.getNext());
return;
}else{
prev=curr;
curr= curr.getNext();
}
}
return;
}}
// new method
public void first(NodeClass listList){
NodeClass front;
front= listList;
System.out.println("The contents of the first node contains: "+ front.getWord());
}
//new method
public void last(NodeClass listList){
NodeClass front;
front= listList;
while(front.getNext()!= null){
front=front.getNext();}
System.out.println("The contents of the last node contains: "+ front.getWord());
}
public boolean search(NodeClass listList, String rmString){
NodeClass front;
front=listList;
while(front!= null){
if(front.getWord() == rmString){
return true;
}else{front=front.getNext();
}
}return false;
}
//new method
public int count(NodeClass listList){
NodeClass curr;
curr = listList;
int count=0;
while(curr != null){
curr = curr.getNext();
count++;
}
return count;
}
// Next Method
public int reader2(NodeClass listList){
int userInt;
System.out.println("Enter size of string that you want to search for: ");
Scanner inputDevice = new Scanner(System.in);
userInt = inputDevice.nextInt();
return userInt;
}
//Next method
public int search(NodeClass listList, int userInt){
int count=0;
while(listList != null){
if(listList.getSize()== userInt){
count++;
listList = listList.getNext();
}else {listList=listList.getNext();}
}return count;
}
}
MY NODECLASS CODE:
public class NodeClass{
int size;
String word;
NodeClass next;
public NodeClass(){
size = 0;
word = "";
next = null;
}
public NodeClass(int s, String w, NodeClass n){
word = w;
size = s;
next = n;
}
public String getWord(){
return word;
}
public int getSize(){
return word.length();
}
public NodeClass getNext(){
return next;
}
public void setWord(String w){
word = w;
}
public void setSize(int s){
size = s;
}
public void setNext(NodeClass n){
next = n;
}
}
I have 13 errors in it compiles in my driver:
Driver.java:15: error: constructor LinkList in class LinkList cannot be applied to given types;
public class Driver extends LinkList
^
required: NodeClass
found: no arguments
reason: actual and formal argument lists differ in length
Driver.java:19: error: constructor LinkList in class LinkList cannot be applied to given types;
LinkList l = new LinkList();
^
required: NodeClass
found: no arguments
reason: actual and formal argument lists differ in length
Driver.java:23: error: non-static variable word cannot be referenced from a static context
l.insert(word, listList);
^
Driver.java:23: error: cannot find symbol
l.insert(word, listList);
^
symbol: variable listList
location: class Driver
Driver.java:24: error: cannot find symbol
l.print(listList);
^
symbol: variable listList
location: class Driver
Driver.java:25: error: non-static variable word cannot be referenced from a static context
}while(word != "stop");
^
Driver.java:29: error: cannot find symbol
l.remove(listList, word);
^
symbol: variable listList
location: class Driver
Driver.java:29: error: non-static variable word cannot be referenced from a static context
l.remove(listList, word);
^
Driver.java:30: error: cannot find symbol
l.print(listList);
^
symbol: variable listList
location: class Driver
Driver.java:31: error: cannot find symbol
}while(rmString != "done");
^
symbol: variable rmString
location: class Driver
Driver.java:33: error: cannot find symbol
l.first(listList);
^
symbol: variable listList
location: class Driver
Driver.java:34: error: cannot find symbol
l.last(listList);
^
symbol: variable listList
location: class Driver
Driver.java:35: error: cannot find symbol
l.count(listList);
^
symbol: variable listList
location: class Driver
13 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
