Results 1 to 3 of 3
  1. #1
    Mr.VicSage is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Default Need help programming a game like "Guess Who"

    I have to create a text-based version of the popular Hasbro game Guess Who.

    In this project you will write a program to play Guess Who using an ArrayList of Person objects to represent
    the set of people and a Picture object to display the “board” of faces. You will create three classes called Person, GuessWho, and PlayGuessWho which will allow the user to play the game. When run, this program will display the image of the faces and ask the user to guess a feature or a name. After the user enters a guess, the GuessWho class will evaluate their guess and give them feedback on whether it matches the mystery person. This will repeat until the user successfully guesses who!
    The Guess Who “faces” image mentioned is in the provided link. This is the image you should display when the user plays Guess Who.
    A text file is also in the download link, describing the faces displayed in the image. You must
    read in this file in and use the data to populate the “Person”s in the GuessWho game. The file is organized
    as follows:
    Name:gender:hairColor:eyeColor:hasGlasses:hasBeard :hasMustache:
    For example, Margaret is female with white hair, blue eyes, glasses, and neither a beard nor a mustache,
    so her line is as follows:
    Margaret:female:white:blue:true:false:false:

    PERSON
    Create a new class called Person.
    Fields:
    •private String name
    •private String gender
    •private String eyeColor
    •private String hairColor
    •private boolean hasGlasses
    •private boolean hasBeard
    •private boolean hasMustache

    Constructors:
    • None.

    Methods:
    •Accessors for all fields
    • Each field listed above should have an accessor method
    • The name of each method must contain “get” and the field name
    • No accessor method may take in a parameter
    • Each method must have a return type matching the field it accesses

    •Modifiers for all fields
    • Each field listed above should have a modifier method
    • The name of each method must contain “set” and the field name
    • Each method may take in a parameter of the same type as the field it modifies
    • Each method must have a return type of void

    •public static Person parsePerson(String parseString, String delim)
    • This method must parse the given parseString according to the given delim, and return a
    new Person object. The method will utilize the modifiers in the Person class to set the features
    of the Person object.
    [NOTE: this method is static, indicating that it is a class method. Refer to section 3.3 in
    the textbook for help.]

    •public String toString()
    • This method must return a String representation of this Person object. It should include the
    person’s name, gender, and other features in a human-readable format.

    GUESSWHO
    Create a new class called GuessWho.
    Fields:
    •private ArrayList people
    •private Person mysteryPerson
    •private Picture display
    •private String guess

    Constructors:
    •public GuessWho(String fileName)
    • This constructor should call a method below to read the given file into the people ArrayList.
    • It must also call a method below to initialize the mysteryPerson field.
    • It must also display the Guess Who faces image.

    Methods:
    •public void playOneTurn()
    • This method should print out a message to the user prompting them to input a feature or name.
    • It should use a scanner to read in the user’s guess, save it to the appropriate field, and call the
    checkGuess method. It should not handle more than one turn.
    •public void checkGuess()
    • This method will print out feedback to the user about their guess.
    • This method should call the isOver method to determine if the user has won the game, printing
    a message if this is the case.
    • This method should check the user’s guess against the mystery person’s features, then print a
    message whether they are correct or incorrect. If your method cannot determine what the user
    is asking (ie: “zebra” is not a valid guess for anything), then print out a message saying their
    guess is invalid. [See Example below for details on output]
    •public boolean isOver()
    • This method should check the user’s guess against the mysteryPerson‘s name, then return
    true or false (whether the game is over, whether the user has guessed correctly).
    •public Person pickMysteryPerson()
    • This method will randomly select a Person object from the people ArrayList, and return it.
    •public ArrayList readFromFile(String fileName)
    • This method will open the given file for reading. It should read the file line by line.
    • It will utilize the parsePerson method in Person.java to create a new Person object for
    each line read in (passing the line to that class method).

    PLAYGUESSWHO
    Create a new class called PlayGuessWho.
    Methods:
    •public static void main(String [] args)
    • This class will have only a main method. This main method will do the actual running of the
    program.
    • It will create a new instance of the GuessWho game, then print a “welcome” message to the
    user.
    • Within a loop, this method should call the above described playOneTurn() method to begin
    play. The loop should end when that instance of the game isOver().
    • Once the game is over, the name of the mystery person should be reveled (for full credit, you
    must utilize the toString() method defined in the Person class).

    The following is a the text within the GuessWho.txt file:
    Victoria:female:brown:brown:false:false:false:
    Matthew:male:brown:blue:false:false:false:
    Jennifer:female:brown:green:false:false:false:
    Jonathan:male:bald:blue:false:true:true:
    Linda:female:blonde:brown:true:false:false:
    Ian:male:gray:blue:true:false:false:
    Karen:female:brown:blue:false:false:false:
    John:male:blonde:blue:false:false:false:
    Richard C.:male:bald:blue:true:true:true:
    Mary:female:black:brown:false:false:false:
    Paul:male:black:blue:false:false:false:
    Charlotte:female:black:blue:false:false:false:
    James B.:male:blonde:blue:false:false:false:
    James W.:male:brown:blue:true:false:false:
    Amy:female:brown:blue:false:false:false:
    Margaret:female:white:blue:true:false:false:
    Marjorie:female:gray:blue:true:false:false:
    Richard S.:male:bald:brown:true:false:true:
    Catherine:female:blonde:blue:false:false:false:
    Nicholas:male:bald:blue:false:true:true:
    Claire:female:blonde:blue:false:false:false:
    Simon:male:brown:blue:true:false:false:
    Tracey:female:brown:brown:false:false:false:
    Philip:male:gray:blue:false:false:false:

    The following is a link to GuessWho.jpg and for Dr. Java:
    MEGAUPLOAD - The leading online storage and file delivery service
    Dr.Java.rar - download now for free. File sharing. Software file sharing. Free file hosting. File upload. FileFactory.com

    Thank you very much for your help in advance

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,229
    Rep Power
    19

    Default

    Cross posted
    OTN Discussion Forums : Need help programming a game like ...

    This is a forum, not a homework service. Recommended reading: How to ask questions the smart way

    db

  3. #3
    Mr.VicSage is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Default

    I apologize. I didn't know I couldn't do that.
    Feel free to delete this thread.

Similar Threads

  1. Replies: 7
    Last Post: 08-13-2010, 07:02 PM
  2. Replies: 2
    Last Post: 08-05-2010, 04:49 AM
  3. Java Applet Help - Making "Snake" Game
    By Alphimeda in forum Java Applets
    Replies: 15
    Last Post: 04-04-2010, 05:39 PM
  4. Programming "MONEY CONVERTER" ???
    By Pascal Nouma in forum New To Java
    Replies: 1
    Last Post: 03-25-2009, 08:26 AM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 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
  •