Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Text adventure game help

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Text adventure game help

    Hello i am currently starting to write a text adventure game in java but i havent been able to find a line of code that allows the computer to keep going and not end after displaying a the first message. Im using Eclipse classic if that makes any diffrence also im using this as a reference:

    import java.util.Scanner;
    public class Custom_Methods_Return_Statements_and_Parameters {

    static Scanner input = new Scanner(System.in);
    public static void main(String[] args){


    }
    public static void inputTest(){
    String message = input.nextLine();
    System.out.println(Hello(message));

    //Note this is case sensitive if you type Hi instead of hi it will not say Hello!
    }


    public static String Hello(String message){
    if (message.equals("Hi")){
    return "Hello";
    }else{
    return "Goodbye";
    }
    }
    }
    <YOUR CODE HERE>


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Text adventure game help

    allows the computer to keep going and not end
    Are you asking how to write a loop that will keep going?

    Please edit your post and wrap your code with code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    Death_The_Kid (April 25th, 2013)

  4. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Text adventure game help

    Yes that is what i am looking for a line of code that will allow it to continue but wont repeat the same message as some suggestions have done. Thank you for responding!

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Text adventure game help

    Here are links to the tutorial for some loop statements:
    The while and do-while Statements (The Java™ Tutorials > Learning the Java Language > Language Basics)
    The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Text inside Text Field
    By JosPhantasmE in forum Java Theory & Questions
    Replies: 1
    Last Post: March 16th, 2013, 05:29 AM
  2. Help with simple text game...
    By iansmiler in forum Java Theory & Questions
    Replies: 5
    Last Post: May 24th, 2012, 01:37 PM
  3. Beginner I/O Help: Writing To a Text File At the End of Existing Lines of Text
    By BloomingNutria in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: February 28th, 2012, 03:03 PM
  4. Replies: 0
    Last Post: October 29th, 2011, 02:37 AM
  5. Text file to text area and Radiobuttons?
    By donaldmax in forum What's Wrong With My Code?
    Replies: 9
    Last Post: May 27th, 2011, 04:45 AM

Tags for this Thread