Results 1 to 4 of 4
  1. #1
    Acar25 is offline Member
    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Default Name entry for text based game.

    I doubt the title of this is very helpful. But i am currently working on a simple text based game where a man asks your gender then asks your name. I am stuck on the name part. I want the program to take what you type in and define a string value as that. I am using Eclipse compiler if that matters. Thanks in advance.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Name entry for text based game.

    Please show us what you've tried. Please explain what problems you're having with your code attempt.

  3. #3
    Acar25 is offline Member
    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Default Re: Name entry for text based game.

    package myApp;
    import java.util.Scanner;
    public class MyApp {

    /**
    * @param args
    */

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    String choice;
    Scanner user_in = new Scanner(System.in);
    System.out.println("Welcome to the world of Pokemon!");
    System.out.println("Here you can train, battle, and hang out wth all kinds of uniqe and wondrous creatures");
    System.out.println("How rude of me! My name is Professor Oak. Others call me the Pokemon Professor.");
    System.out.println("Now tell me, are you a boy or girl?");
    choice = user_in.nextLine();
    if (choice.equals("boy"))
    {System.out.println("So you're a boy? Wonderful!");}
    else if (choice.equals("girl"))
    {System.out.println("So you're a girl? Wonderful!");}
    else {System.out.println("That was not valid.");}
    System.out.println("Well now that we know your gender. What is your name?");

    }

    }




    This is what i have so far. Now after the line "Well now that we know your gender. What is your name?" I want whatever someone types as their name to set a string value known as name. None of this is in here yet.

  4. #4
    Acar25 is offline Member
    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Default Re: Name entry for text based game.

    No worries guys, i figured it out myself.

Similar Threads

  1. Need help with my text based game
    By czarcalvinsk in forum New To Java
    Replies: 1
    Last Post: 04-08-2012, 12:57 AM
  2. Replies: 2
    Last Post: 08-05-2010, 05:49 AM
  3. creating a text based game
    By Phobos0001 in forum New To Java
    Replies: 1
    Last Post: 02-12-2008, 05:35 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •