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

create a class called WORD which has a static value WORD_SIZE equal to three, an

ID: 3846893 • Letter: C

Question

create a class called WORD which has a static value WORD_SIZE equal to three, and an instance variable which is a String that represents the word. the constructor for the class should take a single String parameter which represents the word that to be stored. For example,

Word w=new Word("cat")

given an input file of words, read the words into an array from the file and display them in a GUI. the GUI should have a GridLayout with one row and two columns. the left should display the words in the order read from the file, and the right column should display the words in sorted order(using selection sort).

as you are reading the words you shoud check that the value read in is legal(3 letters), and if it is not, print it to the console and do not put it in the array of Words.

Submitting the project.

You should have three files to submit for this project:

Project1.java

WordGUI.java

Word.java

this is the text file

Explanation / Answer

Word.java

import java.io.BufferedReader;
import java.io.FileReader;


public class Word {
   private static int WORD_SIZE=3;
   private String var;
   private static int count=0;
   private static String[] varArr;
   Word(String var1)
   {
       var = var1;
       varArr[count]=var1;
       count++;
   }
      
   public static void main(String[] args)
   {
       // TODO Auto-generated method stub
       System.out.println("Hello World");
       String sCurrentLine;
       System.out.println("Hello from Reader class main");
       try
       {
           BufferedReader br = new BufferedReader(new FileReader("TestInput"));
           while ((sCurrentLine = br.readLine()) != null) {
               if(sCurrentLine.length()==3)
               {
                   Word obj = new Word(sCurrentLine);
               }
               else
               {
                   System.out.println(sCurrentLine);
               }
           }
       }
       catch(Exception e)
       {
           e.printStackTrace();
       }
      
       WordGUI.create(varArr);

   }
}

WordGui.java

import java.awt.GridLayout;


public class WordGUI {
   public static void create(String []varArray)
   {
       GridLayout obj1 = new GridLayout(1,2);
   }

}