Advertisement
jmilne22

Untitled

Nov 18th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. /**
  2.  * Created by jmiln_000 on 2014-11-18.
  3.  */
  4. import java.util.Scanner;
  5. import java.util.Arrays;
  6. import java.util.Random;
  7. public class hangman {
  8.     public static void main(String[] args){
  9.         // call methods here
  10.         System.out.println("Welcome to James Word Game!");
  11.         System.out.println(secretWord(words)); // delete this later, for testing purposes only
  12.         System.out.println("I'm ready: I've chosen a word for you to guess!");
  13.         int tries = 10; // initlize number of tries to 10
  14.  
  15.         System.out.printf("You have %d incorrect guesses left.", tries);
  16.     }
  17.     public static String[] words = // array of words to pick from random
  18.             {"casserole", "shareware", "multimedia", "college", "microsoft", "sheridan", "internet", "nintendo", "programming", "undertaker", "playstation" };
  19.     public static String secretWord(String[] words){ // this picks a random word from the array and returns it back to the main method
  20.         Random Dice = new Random();
  21.         int n = Dice.nextInt(10);
  22.         String secretWord = words[n];
  23.         return secretWord;
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement