Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by jmiln_000 on 2014-11-18.
- */
- import java.util.Scanner;
- import java.util.Arrays;
- import java.util.Random;
- public class hangman {
- public static void main(String[] args){
- // call methods here
- System.out.println("Welcome to James Word Game!");
- System.out.println(secretWord(words)); // delete this later, for testing purposes only
- System.out.println("I'm ready: I've chosen a word for you to guess!");
- int tries = 10; // initlize number of tries to 10
- System.out.printf("You have %d incorrect guesses left.", tries);
- }
- public static String[] words = // array of words to pick from random
- {"casserole", "shareware", "multimedia", "college", "microsoft", "sheridan", "internet", "nintendo", "programming", "undertaker", "playstation" };
- public static String secretWord(String[] words){ // this picks a random word from the array and returns it back to the main method
- Random Dice = new Random();
- int n = Dice.nextInt(10);
- String secretWord = words[n];
- return secretWord;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement