hey, can you guys help me with this hangman applet


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: hey, can you guys help me with this hangman applet

  1. #1
    Join Date
    May 2006
    Posts
    3

    hey, can you guys help me with this hangman applet

    Hey guys,

    I need some help with a hangman applet and I figured this would be the place to go. Anyway, its the input I need help with, Im making a hangman game with a friend and Im doing the input while hes doing the other parts.
    So we have the name of the films, books and tv programs for the game as follows in this data file which is saved as a notepad file. This is as follows;

    book
    cold mountain
    book
    stalingrad
    book
    behind the scenes at the museum
    film
    the thomas crown affair
    film
    psycho
    film
    the birds
    film
    mary poppins
    film
    the sound of music
    tv
    bbc news
    tv
    newsnight
    tv
    channel 4 news
    tv
    hollyoaks
    tv
    top gear
    tv
    not the nine o'clock news
    tv
    peak practice
    book
    harry potter and the philosopher's stone
    book
    catch 22
    tv
    columbo
    book
    far from the madding crowd
    tv
    ever decreasing circles
    tv
    the bill
    book
    private papers
    book
    the mill on the floss
    book
    jane eyre
    tv
    goodnight sweetheart
    tv
    fawlty towers
    book
    larry's party
    tv
    coronation street
    book
    northern lights
    film
    angela's ashes
    tv
    eastenders
    film
    the end of the affair
    tv
    frost
    tv
    red dwarf
    film
    the beach
    book
    angela's ashes
    book
    tis
    book
    alias grace
    tv
    top of the pops
    tv
    emerdale
    book
    cat's eye
    tv
    tarrant on tv
    book
    charlotte gray
    tv
    match of the day
    tv
    the simpsons
    book
    beloved
    book
    bird song
    book
    wild swans
    book
    fatherland
    book
    flaubert's parrot
    book
    brazzaville beach
    tv
    casualty
    book
    enduring love
    book
    possession
    film
    titanic
    film
    rugrats
    film
    the piano
    tv
    newsnight
    tv
    the royle family
    tv
    southpark
    film
    mousehunt
    film
    toy story
    book
    the hitchiker's guide to the galaxy
    tv
    brookside
    book
    the comedians
    tv
    only fools and horses
    tv
    neighbours
    tv
    friends
    tv
    frasier
    book
    tom jones
    film
    the green mile
    book
    i claudius
    film
    the sixth sense
    film
    american beauty
    film
    the talented mr ripley
    film
    topsy turvy
    book
    for whom the bell tolls
    book
    the house of the spirits
    film
    double jeopardy
    film
    stigmata
    film
    muppets from space
    book
    a christmas carol
    film
    sleepy hollow
    book
    matilda
    book
    fermats last theorem
    tv
    buffy the vampire slayer
    tv
    star trek
    film
    toy story 2
    book
    gulliver's travels
    book
    great expectations
    tv
    dinnerladies
    tv
    heartbeat
    tv
    london's burning
    tv
    midsomer murders

    As you can see each category is identified by the keyword 'book', 'film', or 'tv', following a line containing the corrosponding title. All text is lowercase and it can be assumed that all text in the file is valid. Also, the info is in no particular order and contains an unspecified number of items. The hangman program we have must read this file of information and then store it in appropriate data structures.
    The way we designed the program, when the applet is run the user will be presented with an applet screen asking them to select a book(1), a film(2) or a TV programme(3). The user will put in their selection and click the enter button. This input box will be displayed at the bottom of the applet screen with the enter button to the right. The user can put in a selection of 1, 2, or 3 and if any other input is provided a messsage will be displayed saying 'invalid input - select a book(1), a film(2) or a TV programme(3). The game will only proceed when a valid input has been inputted. So when a category is correctly inputted, a title from that category will be selected at random.

    Am I right in thinking this is the the input section of the hangman game complete. After this my friends task will be to load the scaffolds and man with the entry of the selected book etc.

    Although how do I do my section of this, I really am stuck and not sure where to even begin. We're meeting up tonight for him to look at my code so I need to have it completed real soon. You guys seem experts on here so any help is greatly appreciated.
    Im using JCreatorLE to make this program if you need to know that.
    So please help me out here, cus I really am stuck with this one.

    Thanks in advance,
    Rik

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    If you are using Java 5 (J2SE 1.5), the Scanner class will be useful in processing your file.

    Have you thought about using an enumeration for the three categories? since you can use enums for switch structure, it makes coding the file processing efficient.

    What data structure are you going to use for the Strings?

  3. #3
    Join Date
    May 2006
    Posts
    3
    This is the code I have so far, but I really am totally lost,

    /**
    * @(#)Hangman.java
    *
    * Sample Applet application
    *
    * @author
    * @version 1.00 06/05/03
    */

    import java.awt.*;
    import java.applet.*;

    public class Hangman extends Applet {

    public void init() {
    }

    public void paint(Graphics g) {
    g.drawString("Welcome to Java!!", 50, 60 );
    }
    }


    public class GuiExample extends Applet
    {

    This is the error I get,

    --------------------Configuration: hangman - JDK version 1.5.0_05 <Default> - <Default>--------------------
    C:\Documents and Settings\rik\My Documents\hangman\src\Hangman.java:25: '}' expected
    {
    ^
    1 error

    Im just wondering, what would be the code for displayed hte java applet window with the input boxes and enter button. Really, any help, code, you can give me for this is very much appreciated.

    With thanks

    Rik

  4. #4
    Join Date
    May 2006
    Posts
    3
    Ive tried like you said there, but I am really stuck and I really need this done as soon as possible so we can move on. I really have no idea where to go from here and now Im starting to panic. Is this a big load of code for this section of the hangman game Ive been assigned to. Im trying to find out more about user input but Im totally lost.
    Really any code you can provide me with is much appreciated, cus I really am very very lost.
    With thanks,
    Rik

Similar Threads

  1. hey guys, Need some help here. :)
    By Xtreme17 in forum VB Classic
    Replies: 1
    Last Post: 12-16-2005, 07:15 PM
  2. JavaMail applet problem
    By Tataroz T. in forum Java
    Replies: 1
    Last Post: 10-20-2005, 07:19 AM
  3. Bouncing Ball Applet
    By nescafe in forum Java
    Replies: 1
    Last Post: 10-07-2005, 09:51 AM
  4. Replies: 3
    Last Post: 08-23-2001, 12:01 PM
  5. Replies: 0
    Last Post: 03-28-2000, 02:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center