hello im new here
and im having problems with this objective.....
here is the instruction.....
General Specification:
Create a game that asks for a player’s name and then shows scrambled letters. The objective
for the game is for the player to guess the unscrambled word. A user is given 2 minutes to guess the
word and the user is given points in the following manner.
• 100 points: if the player guessed the word in the 1st minute.
• 50 points: if the player guessed the word within the succeeding minute.
The player has the option to keep scrambling the letters of the word to be unscrambled
either by clicking the button on the game’s interface or by pressing the spacebar of the keyboard.
This game ends when the player was not able to guess the word within the allowable time or if the
user was able to guess all the words in this game’s list of words to be guessed.
Name and score of the player is shown in the game’s interface if the player beats the current
highest score (the game’s highest score and scorer are shown with 0 and blank, respectively when
the game is first executed).
Detailed Specification:
o The program must read a text file containing 100 words with the following information for
each of the words:
The word (comprising 5 to 7 letters)
The classification of the word: noun, verb, or adjective
Definition of the word
Note: Just choose one classification/definition for the word if it has more than 1
definition.
o You are to use an ArrayList object to store the words read from the file.
o When running the program, the program must jumble all the 100 words before showing the
first word to be guessed. Note also that the jumbled letters of the word are shown to the
player.
o Your game’s interface should provide for the jumbling the letters of the word being guessed
through a button or by pressing the space bar.
o The time remaining for the player to guess must also be shown (starting with 2 minutes
[2:00]).
o When the first minute has elapsed and the player has not yet guessed the word, the word’s
classification (noun, verb, or adjective) is shown together with the definition of the word to
serve as a hint.
o Be creative in creating your game’s interface.
o Make sure that your project’s game interface (GUI) shall utilize a logic class that has the
direct access to the text file.
how do u use the Timer class for this activity?
if im in the wrong thread.....
jst tell me where should i place this thread to ok?.......
ur help is most appreciated......
thanks.......
but they say that you could pattern with this other problem..........
Consider the uml diagram below........
--------------------------------------
for Word:
------------------------------------------
-text:String
-charList:List<Character>
-shuffled;String
-------------------------------------------
+ Word(str:String)
- getChars():Arraylist<Character>
+shuffle():void
- listToString()String
+toString():String
+getShuffleedText():String
--------------------------------------------
*Definition of the diagram above has already been provided (Word.java)
-Study the code and give special attention how the shuffle method has been implemented.
-something to think about: What's the advantage of using the ArrayList as against a regular character array?
*Other than Word.java, another tester file is provided (Tester.java) with the sole purpose ofof trying the code for Word.java. You may run this program and make your own testing using this file.
Requirement:
1. Create a GUI class that Word class provided with the following functionalities:
*Entering a text:
-Display an input dialog box where the user can input the word the user wants to enter.
-When the input is successful, display the word on the main window(the componentmust be restricted from modification/s from the user).
-if the input is invalid(text enteredis less than 3 letters in length), another dialog box must be shown informing the user that the input is invalid. (Check the constructor for Word.java)
*shuffling the text displayed
-The component that allows the user to do this functionality should only be activated if a word is already displayed.
here is the code for Word.java:
/** * @(#)Word.java * * * @author * @version 1.00 2010/8/4 */ import java.util.*; public class Word { private String text; private List<Character> charList; private String shuffled; public Word(String str) { if (str.length() < 3) { throw new RuntimeException("Word must be more than 2 characters..."); } text = str.toUpperCase(); charList = getChars(); shuffle(); } private ArrayList<Character> getChars() { ArrayList<Character> tempList = new ArrayList<Character>(); for (int i = 0; i < text.length(); i++) { tempList.add(text.charAt(i)); } return tempList; } public void shuffle() { String orig = shuffled; String tempShuffled; do { Collections.shuffle(charList); tempShuffled = listToString(); } while (tempShuffled.equals(orig) || tempShuffled.equals(text)); shuffled = tempShuffled; } private String listToString() { String strTemp = ""; for (Character ch: charList) { strTemp += ch; } return strTemp; } public String toString() { return text; } public String getShuffledText() { return shuffled; } }
and here's the code for Tester.java:
/** * @(#)Tester.java * * * @author * @version 1.00 2010/8/4 */ public class Tester { public static void main(String[] args) { divider(); Word w = new Word("caterpillar"); System.out.println("word is: " + w); System.out.println("Succeeding lines are calls to shuffling the letters of the word:"); System.out.println(w.getShuffledText()); w.shuffle(); System.out.println(w.getShuffledText()); w.shuffle(); System.out.println(w.getShuffledText()); w.shuffle(); System.out.println(w.getShuffledText()); w.shuffle(); System.out.println(w.getShuffledText()); w.shuffle(); System.out.println(w.getShuffledText()); w.shuffle(); System.out.println(w.getShuffledText()); divider(); // further testing below (eg. what if the assigned word to w is less than 2 in length such as "to") w = new Word("to"); } private static void divider() { System.out.println("============================"); } }
and here's what's wrong with my code
its about the gui class that should go along with word.java and tester.java.....
if u know and corrections or solutions to complete this program
just let me know ok?
anyways here is my unfinished gui code:
/** * @(#)MainGUI.java * * * @author * @version 1.00 2010/8/5 */ import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MainGUI extends JFrame { private JTextField txtWordInput; private JButton btnShuffle; private JButton btnClear; private JButton btnExit; private JLabel Word; private JPanel panel; public MainGUI() { GridBagConstraints c = new GridBagConstraints(); GridBagLayout gbl = new GridBagLayout(); panel = new JPanel(); panel.setLayout(gbl); txtWordInput = new JTextField(20); btnShuffle = new JButton("Shuffle"); btnShuffle.addActionListener(new buttonHandler()); btnClear = new JButton("Clear"); btnShuffle.addActionListener(new buttonHandler()); btnExit = new JButton("Exit"); btnExit.addActionListener(new buttonHandler()); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { } } }