Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. package content;
  2.  
  3. import java.util.Arrays;
  4. import javax.swing.JOptionPane;
  5. import static content.Content.show;
  6.  
  7. public class Content {
  8.  
  9. static String nameprompter[] = new String[5];
  10. static int bendover = 0;
  11.  
  12. @SuppressWarnings("empty-statement")
  13. public static void main(String[] args) {
  14. String puzzle[] = {"p", "r", "i", "n", "c", "e"};
  15. String display[] = {"", "", "", "", "", ""};
  16. String guess;
  17. String choice = JOptionPane.showInputDialog(null, "Do you want to play agian \n 1. Yes \n 2. No");
  18. boolean done = false;
  19.  
  20. if (!choice.equals("yes")) {
  21. } else {
  22. boolean goodGuess = false;
  23.  
  24. do {
  25.  
  26. guess = JOptionPane.showInputDialog("Guess a letter in the puzzle");
  27. goodGuess = false;
  28.  
  29. for (int i = 0; i < puzzle.length; i++) {
  30. if (puzzle[i].equals(guess)) {
  31. display[i] = guess;
  32. goodGuess = true;
  33. }
  34. }
  35. if (goodGuess == false) {
  36. JOptionPane.showMessageDialog(null, "wrong");
  37. }
  38. if (goodGuess == true) {
  39. JOptionPane.showMessageDialog(null, "right");
  40. show(display);
  41.  
  42. }
  43. if (Arrays.toString(puzzle).equals(Arrays.toString(display))) {//sets both arrays equal when the user gets the word
  44. for (int i = 0; i < nameprompter.length; i++) {
  45. System.out.println(nameprompter[i] + " got " + bendover + " points.");
  46. }
  47. break;
  48. }
  49.  
  50. } while (done == false);
  51.  
  52. }
  53. }
  54.  
  55. public static void show(String display[]) {
  56. for (String display2 : display) {
  57. System.out.print(" " + display2);
  58. }
  59. System.out.println("");
  60.  
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement