Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package content;
- import java.util.Arrays;
- import javax.swing.JOptionPane;
- import static content.Content.show;
- public class Content {
- static String nameprompter[] = new String[5];
- static int bendover = 0;
- @SuppressWarnings("empty-statement")
- public static void main(String[] args) {
- String puzzle[] = {"p", "r", "i", "n", "c", "e"};
- String display[] = {"", "", "", "", "", ""};
- String guess;
- String choice = JOptionPane.showInputDialog(null, "Do you want to play agian \n 1. Yes \n 2. No");
- boolean done = false;
- if (!choice.equals("yes")) {
- } else {
- boolean goodGuess = false;
- do {
- guess = JOptionPane.showInputDialog("Guess a letter in the puzzle");
- goodGuess = false;
- for (int i = 0; i < puzzle.length; i++) {
- if (puzzle[i].equals(guess)) {
- display[i] = guess;
- goodGuess = true;
- }
- }
- if (goodGuess == false) {
- JOptionPane.showMessageDialog(null, "wrong");
- }
- if (goodGuess == true) {
- JOptionPane.showMessageDialog(null, "right");
- show(display);
- }
- if (Arrays.toString(puzzle).equals(Arrays.toString(display))) {//sets both arrays equal when the user gets the word
- for (int i = 0; i < nameprompter.length; i++) {
- System.out.println(nameprompter[i] + " got " + bendover + " points.");
- }
- break;
- }
- } while (done == false);
- }
- }
- public static void show(String display[]) {
- for (String display2 : display) {
- System.out.print(" " + display2);
- }
- System.out.println("");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement