Results 1 to 3 of 3
  1. #1
    swamymonish is offline Member
    Join Date
    Jun 2013
    Location
    Melbourne
    Posts
    3
    Rep Power
    0

    Default Coding in inputs in Java

    Hi fellow Java Lovers,
    I am currently programming a small game from the knowledge I know, and its just a basic game where you guide yourself around a haunted house and try to find the exit.
    Only problem is I don't know how to program user inputs into the program.

    eg. Here is a piece of my code
    "
    protected void goRightThree()
    {
    System.out.println("You walk forward, trying not to make too much noise");
    System.out.println("You come to a left turn and right turn which way do you go?");
    double randomNumber = Math.random();
    if (randomNumber >= 0.5)
    {
    System.out.println("You decide to go left");
    System.out.println("");
    goLeftFour();
    }

    else
    {
    System.out.println("You decide to go right");
    System.out.println("");
    goRightFour();
    }
    "

    For the time being I just made the direction the user goes as a random decision but what I am aiming to do is make the user of this game be able to choose where he/she goes.
    I know people probably thinking I am very new to Java but help would be very nice.


    Thanks guys

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: Coding in inputs in Java

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: Coding in inputs in Java

    Quote Originally Posted by swamymonish View Post
    Only problem is I don't know how to program user inputs into the program.
    I/O from the Command Line (The Java™ Tutorials > Essential Classes > Basic I/O)
    Scanner (Java Platform SE 7 )

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 1
    Last Post: 10-24-2012, 01:21 PM
  2. Replies: 3
    Last Post: 09-06-2012, 06:30 PM
  3. Replies: 4
    Last Post: 10-25-2010, 04:49 PM
  4. Giving Inputs to Java Applet
    By rasikh in forum Java Applets
    Replies: 2
    Last Post: 10-05-2009, 04:08 PM
  5. Java program that stores user inputs
    By staticy2003 in forum Advanced Java
    Replies: 6
    Last Post: 01-24-2008, 08:46 PM

Posting Permissions

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