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

Create a class called WordNode which has fields for the data (a Word) and next (

ID: 3803955 • Letter: C

Question

Create a class called WordNode which has fields for the data (a Word) and next (WordNode) instance variables. Include a one-argument constructor which takes a Word as a parameter. (For hints, see the PowerPoint on "Static vs. Dynamic Structures”.) public WordNode (Word w) { . . } The instance variables should have private access. There will not be any get and set methods for the two instance variables. Create linked list class called WordList. This should be a linked list with head node as described in lecture. Modify it so that the data type in the nodes is Word. The no-argument constructor should create an empty list with first and last pointing to an empty head node, and length equal to zero. Include two methods in class WordList: append and insert. The append method will add the new node to the end of the list; the insert method will add the node in the proper position to keep the list sorted in order by Word. Instantiate two linked lists, and for every Word read from the file, add it (if it is three letters) to the first list using append, and to the second list using insert. You will end up with the first list having the Words from the input file in the order they were read, and in the second list the Words will be in sorted order. Display the unsorted and sorted Words in the GUI.

It should include :

Project2.java

Word.java

WordGUI.java

WordNode.java

WordList.java

Explanation / Answer

Find the below answer for the above question asked:

WordGUI.java

****************

package com.sql.acadgild;

import java.io.FileNotFoundException;

public class WordGUI {

   public WordGUI() {
       // TODO Auto-generated constructor stub
   }

  
   public static void main(String[] args) {
      
       WordList wordList=new WordList();
       try {
           wordList.insert();//sort list
           wordList.append();//unsorted list
       } catch (FileNotFoundException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
       }
      
   }
}

***************

WordList.java

*******************

package com.sql.acadgild;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class WordList {


   WordNode wordNode;

   List mylist;  
   List myList2;

   public WordList() {
       super();
       mylist=new ArrayList();
       myList2=new ArrayList();
       if(mylist.isEmpty()||mylist.size()==0){
           System.out.println("Length is empty and length is zero");
       }

   }


   void append(){

       int   listSize=mylist.size();
       for(int i = 0; i < listSize; ++i)
           mylist.add("whatever");
   }


   void insert() throws FileNotFoundException{
       mylist.add("one");
       mylist.add("two");
       for (int i = 0; i < mylist.size(); i++) {
           Collections.sort(mylist);
       }

       Scanner s = new Scanner(new File("filepath"));
       while (s.hasNext()) {

           myList2.add(s.next());
       }
       s.close();
   }

   public WordList(WordNode wordNode) {
       super();
       this.wordNode = wordNode;
   }


}

******************

WordNode.java

****************

package com.sql.acadgild;

public class WordNode {

   private String Word;
   private String WordNode;
   public WordNode(String word) {
       super();
       Word = word;
   }

}

**************

P.S for the execution purpose please read a text file with adding your own input values to get the exact output of your choice as per the asked question.

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