Results 1 to 3 of 3
  1. #1
    nobody58 is offline Member
    Join Date
    Mar 2010
    Posts
    14
    Rep Power
    0

    Default I'm stuck help!!!

    hi I started this code I know that there is errors and it's not complete

    I'm trying to make the computer guess a word from the array and than If I guess the word it will say I won and If i didn't it will say I lost

    this is the code:

    Java Code:
    import java.util.*;
    
    
    // this is the class
    public class WordGuesser {
    private InputReader input;
    private words arraylist;
    
    
    
    public static String word = null;
        public void main() {
            System.out.println("guess the word?");
            word = input.nextLine();
    
         
         String [] words;              // declares an array of integers
    
              words = new String [15];      // allocates memory for 10 integers
                
              words[0] = "hello"; // initialize first element
              words[1] = "car"; // initialize second element
              words[2] = "dog"; 
              words[3] = "plane";
              words[4] = "plant";
              words[5] = "help";
              words[6] = "job";
              words[7] = "java";
              words[8] = "blue";
              words[9] = "bathroom";
              words[10] = "word";
              words[11] = "apple";
              words[12] = "orange";
              words[13] = "paper";
              words[14] = "stone";
     
         }
    
    }
    
      if (get.words[] == word){
               System.out.println ("you won");
            }
       
               while (get.words[]!=word){
               
               System.out.println ("you lost");
               word = input.nextLine();
    
                    }
                }
            }
        }

    I was given this code for an input reader that I don't know how to use if there is a possibility can you give me a hint on how to use it

    this is the code for the input reader:

    Java Code:
    import java.util.Scanner;
    
    /**
     * InputReader reads text input from the text terminal. 
     */
    public class InputReader
    {
      private Scanner reader;
    
      /**
       * Create a new InputReader that reads from the terminal
       */
      public InputReader()
      {
        reader = new Scanner(System.in);
      }
    
      public String getString()
      {
        String input = reader.nextLine();
        return input;
      }
        
      public int getInt()
      {
        int input = reader.nextInt();
        reader.nextLine();
        return input;
      }
    
    }

  2. #2
    nobody58 is offline Member
    Join Date
    Mar 2010
    Posts
    14
    Rep Power
    0

    Default

    the programme I'm using is bluej

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,655
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by nobody58 View Post
    I was given this code for an input reader that I don't know how to use if there is a possibility can you give me a hint on how to use it
    Are you too lazy to read (and understand) the source code? It's a very simple class with one constructor (it doesn't take arguments). An instantiation of an InputReader can read entire lines (a String) or a single int from a line (and it skips the rest of that line). It doesn't take rocket science to understand such a class. Programming is not about collecting code (that you don't understand) and trying to glue it together.

    the programme I'm using is bluej
    I have a very old, fully functional (but noisy) espresso machine (also completely irrelevant).

    kind regards,

    Jos

Similar Threads

  1. Stuck in sea
    By programmer_007 in forum JDBC
    Replies: 1
    Last Post: 09-17-2009, 04:00 AM
  2. Im on my last lab!!!! And im stuck...:(
    By clanboru15 in forum New To Java
    Replies: 5
    Last Post: 03-13-2009, 01:44 AM
  3. really stuck now..
    By shongo in forum Advanced Java
    Replies: 2
    Last Post: 11-09-2008, 02:56 AM
  4. Stuck in need of help!
    By Zombie_Leg! in forum New To Java
    Replies: 1
    Last Post: 09-23-2008, 02:22 AM
  5. I am completely stuck
    By jpnym15 in forum New To Java
    Replies: 2
    Last Post: 11-14-2007, 06:40 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
  •