Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. /*
  2. * Sean Luava
  3. * 4/23/16
  4. */
  5. import javax.swing.*;
  6. public class Button
  7. {
  8. private int bat;
  9. private boolean car;
  10. private boolean frk;
  11.  
  12. public Button(int b, String[] lit)
  13. {
  14. bat = b;
  15. car = false;
  16. frk = false;
  17. for(int aa = 0; aa < lit.length; aa++)
  18. {
  19. if(lit[aa].equals("car"))
  20. car = true;
  21. if(lit[aa].equals("frk"))
  22. frk = true;
  23. }
  24. }
  25.  
  26. public void run()
  27. {
  28. String color = JOptionPane.showInputDialog("Enter color of the button:");
  29. color = color.toLowerCase();
  30. String word = JOptionPane.showInputDialog("Enter word on the button:");
  31. word = word.toLowerCase();
  32. boolean hold = false;
  33. String strip = "";
  34.  
  35. if((color.equals("blue")) && (word.equals("abort")))
  36. {
  37. strip = JOptionPane.showInputDialog("Hold down the button and enter the color of the strip:");
  38. hold = true;
  39. }
  40. else if((bat > 1) && (word.equals("detonate")))
  41. {
  42. JOptionPane.showMessageDialog(null, "Press and immediately release the button.");
  43. }
  44. else if((color.equals("white")) && (car))
  45. {
  46. strip = JOptionPane.showInputDialog("Hold down the button and enter the color of the strip:");
  47. hold = true;
  48. }
  49. else if((bat > 2) && (frk))
  50. {
  51. JOptionPane.showMessageDialog(null, "Press and immediately release the button.");
  52. }
  53. else if(color.equals("yellow"))
  54. {
  55. strip = JOptionPane.showInputDialog("Hold down the button and enter the color of the strip:");
  56. hold = true;
  57. }
  58. else if((color.equals("red")) && (word.equals("hold")))
  59. {
  60. JOptionPane.showMessageDialog(null, "Press and immediately release the button.");
  61. }
  62. else
  63. {
  64. strip = JOptionPane.showInputDialog("Hold down the button and enter the color of the strip:");
  65. hold = true;
  66. }
  67.  
  68. if(hold)
  69. {
  70. strip = strip.toLowerCase();
  71. holding(strip);
  72. }
  73. }
  74. private void holding(String s)
  75. {
  76. int digit = 1;
  77. switch(s)
  78. {
  79. case "blue":
  80. digit = 4;
  81. break;
  82. case "yellow":
  83. digit = 5;
  84. break;
  85. }
  86. JOptionPane.showMessageDialog(null, "Release when the countdown timer has a " + digit + " in any position.");
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement