Question: Urgent! Urgent!!!!!! import java.io . File; import java.io . FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextArea; public class Project
Urgent! Urgent!!!!!!
import java.ioFile;
import java.ioFileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
public class Project extends JFrame
private static final int MINWORDLENGTH ;
private String puzzleLetters;
private ArrayList solutions;
private JTextArea foundWordsArea;
private JLabel scoreLabel;
public ProjectString fileName throws FileNotFoundException
superSpelling Beehive";
this.solutions new ArrayList;
this.readInputfileName;
this.createGUI;
this.scoreLabel.setTextScore: ;
private void readInputString fileName throws FileNotFoundException
File file new FilefileName;
Scanner scanner new Scannerfile;
this.puzzleLetters scanner.nextLinetoUpperCase;
while scannerhasNextLine
solutions.addscannernextLinetoUpperCase;
scanner.close;
private void createGUI
PuzzleGUI puzzleGUI new PuzzleGUIpuzzleLetters;
this.addpuzzleGUI;
this.setSize;
this.setVisibletrue;
this.setDefaultCloseOperationJFrameEXITONCLOSE;
public void playGame
while true
String guess JOptionPane.showInputDialogthis "Enter a word at least letters:toUpperCase;
if guess null
break;
if isValidWordguess
continue;
if solutionscontainsguess
foundWordsArea.appendguess
;
solutions.removeguess;
scoreLabel.setTextScore: foundWordsArea.getLineCount;
else
JOptionPane.showMessageDialogthis "Invalid guess!";
private boolean isValidWordString guess
if guesslength MINWORDLENGTH
JOptionPane.showMessageDialogthis "Word must be at least letters long!";
return false;
for char letter : guess.toCharArray
if puzzleLetters.containsStringvalueOfletter
JOptionPane.showMessageDialogthis "Word contains invalid letters!";
return false;
return true;
public static void mainString args
if argslength argsequalsPinput.txt
System.out.printlnUsage: java Project Pinput.txt;
System.exit;
try
Project game new Projectargs;
game.playGame;
catch FileNotFoundException e
System.out.printlnError: Input file not found!";
eprintStackTrace;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class PuzzleGUI extends JPanel
private JTextArea foundWordsArea;
private JLabel scoreLabel;
public PuzzleGUIString puzzleLetters
this.setLayoutnew java.awt.GridLayout;
JLabel letterLabel new JLabelPuzzle Letters: puzzleLetters;
foundWordsArea new JTextArea;
foundWordsArea.setEditablefalse;
scoreLabel new JLabelScore: ;
this.addletterLabel;
this.addfoundWordsArea;
public JTextArea getFoun
Improving on the Word Game Add the following improvements to the word game. The first letter of the subject letters the first line of the input file must be contained in all the correct guessed words. If a guessed word contains ALL of the subject letters, that is worth points. Display the correctly guessed words in alphabetical order. Lists of Words Create a class called WordNode which has fields for the data a Word and next WordNode instance variables. Include a oneargument 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 protected access. Create an abstract 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 noargument constructor should create an empty list with first and last pointing to an empty head node, and length equal to zero. Include an append method in this class. Create two more linked list classes that extend the abstract class WordList: One called UnsortedWordList and one called SortedWordList, each with appropriate noargument constructors. Each of these classes should have a method called addWord that will add a new node to the list. In the case of the UnsortedWordList it will add it to the end of the list by calling the append method in the super class. In the case of the SortedWordList it will insert the node in the proper position to keep the list sorted. Instantiate two linked lists, one sorted and one unsorted. Add the solutions from the input file to the unsorted linked list. This list will be searched to see if a guessed word matches. As words are correctly guessed, add them to the sorted list and display the contents of that list in the TextArea for the guessed words. Check the method setText in class TextArea to update the contents of the TextArea.
Now write the improvement of this code withing today to get good review!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
