Advertisement
Guest User

Script

a guest
Jun 6th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.43 KB | None | 0 0
  1. package colorguesser;
  2.  
  3. import javax.swing.JOptionPane;
  4.  
  5. /**
  6. *
  7. * @author Jesse
  8. */
  9. public class ColorGuesser {
  10.  
  11. private static int num;
  12.  
  13. public static void main(String[] args) {
  14.  
  15. int a = JOptionPane.YES_OPTION;
  16. int b = JOptionPane.YES_OPTION;
  17. int c = JOptionPane.YES_OPTION;
  18. int right=0, wrong=0, tries=0;
  19.  
  20. while (a == JOptionPane.YES_OPTION ) {
  21. Object[] Choice = {"Red", "Green", "Blue", "Yellow"};
  22. String R = (String)JOptionPane.showInputDialog(
  23. null,
  24. "What is your first choice: \n",
  25. "Your Choice",
  26. JOptionPane.PLAIN_MESSAGE,
  27. null,
  28. Choice,
  29. "Red");
  30.  
  31. Object[] Choice2 = {"Red", "Green", "Blue", "Yellow"};
  32. String B = (String)JOptionPane.showInputDialog(
  33. null,
  34. "What is your second choice: \n",
  35. "Your Choice",
  36. JOptionPane.PLAIN_MESSAGE,
  37. null,
  38. Choice2,
  39. "Red");
  40.  
  41. Object[] Choice3 = {"Red", "Green", "Blue", "Yellow"};
  42. String G = (String)JOptionPane.showInputDialog(
  43. null,
  44. "What is your third choice: \n",
  45. "Your Choice",
  46. JOptionPane.PLAIN_MESSAGE,
  47. null,
  48. Choice3,
  49. "Red");
  50.  
  51. tries = tries+1;
  52. System.out.println("\nYou are on try: " + tries + "\n");
  53.  
  54. if ("Red".equals(R)) {
  55. num = (int) (Math.random()*4+1);
  56. if (num==1) {
  57. right = right+1;
  58. System.out.println("You picked Red and the computer had also picked Red! (Right)");
  59. }
  60. if (num==2) {
  61. wrong = wrong+1;
  62. System.out.println("You picked Red and the computer had picked Green! (Wrong)");
  63. }
  64. if (num==3) {
  65. wrong = wrong+1;
  66. System.out.println("You picked Red and the computer had picked Blue! (Wrong)");
  67. }
  68. if (num==4) {
  69. wrong = wrong+1;
  70. System.out.println("You picked Red and the computer had picked Yellow! (Wrong)");
  71. }
  72. }
  73. if ("Green".equals(R)) {
  74. num = (int) (Math.random()*4+1);
  75. if (num==1) {
  76. wrong = wrong+1;
  77. System.out.println("You picked Green and the computer had picked Red! (Lose)");
  78. }
  79. if (num==2) {
  80. right = right+1;
  81. System.out.println("You picked Green and the computer had also picked Green! (Win)");
  82. }
  83. if (num==3) {
  84. wrong = wrong+1;
  85. System.out.println("You picked Green and the computer had picked Blue! (Lose)");
  86. }
  87. if (num==4) {
  88. wrong = wrong+1;
  89. System.out.println("You picked Green and the computer had picked Yellow! (Lose)");
  90. }
  91. }
  92. if ("Blue".equals(R)) {
  93. num = (int) (Math.random()*4+1);
  94. if (num==1) {
  95. wrong = wrong+1;
  96. System.out.println("You picked Blue and the computer had picked Red! (lose)");
  97. }
  98. if (num==2) {
  99. wrong = wrong+1;
  100. System.out.println("You picked Blue and the computer had picked Green! (Lose)");
  101. }
  102. if (num==3) {
  103. right = right+1;
  104. System.out.println("You picked Blue and the computer had also picked Blue! (Win)");
  105. }
  106. if (num==4) {
  107. wrong = wrong+1;
  108. System.out.println("You picked Blue and the computer had picked Yellow! (Lose)");
  109. }
  110. }
  111. if ("Yellow".equals(R)) {
  112. num = (int) (Math.random()*4+1);
  113. if (num==1) {
  114. wrong = wrong+1;
  115. System.out.println("You picked Yellow and the computer had picked Red! (Lose)");
  116. }
  117. if (num==2) {
  118. wrong = wrong+1;
  119. System.out.println("You picked Yellow and the computer had picked Green! (Lose)");
  120. }
  121. if (num==3) {
  122. wrong = wrong+1;
  123. System.out.println("You picked Yellow and the computer had picked Blue! (Lose)");
  124. }
  125. if (num==4) {
  126. right = right+1;
  127. System.out.println("You picked Yellow and the computer had also picked Yellow! (Win)");
  128. }
  129. }
  130. if ("Red".equals(B)) {
  131. num = (int) (Math.random()*4+1);
  132. if (num==1) {
  133. right = right+1;
  134. System.out.println("You picked Red and the computer had also picked Red! (Right)");
  135. }
  136. if (num==2) {
  137. wrong = wrong+1;
  138. System.out.println("You picked Red and the computer had picked Green! (Wrong)");
  139. }
  140. if (num==3) {
  141. wrong = wrong+1;
  142. System.out.println("You picked Red and the computer had picked Blue! (Wrong)");
  143. }
  144. if (num==4) {
  145. wrong = wrong+1;
  146. System.out.println("You picked Red and the computer had picked Yellow! (Wrong)");
  147. }
  148. }
  149. if ("Green".equals(B)) {
  150. num = (int) (Math.random()*4+1);
  151. if (num==1) {
  152. wrong = wrong+1;
  153. System.out.println("You picked Green and the computer had picked Red! (Wrong)");
  154. }
  155. if (num==2) {
  156. right = right+1;
  157. System.out.println("You picked Green and the computer had also picked Green! (Right)");
  158. }
  159. if (num==3) {
  160. wrong = wrong+1;
  161. System.out.println("You picked Green and the computer had picked Blue! (Wrong)");
  162. }
  163. if (num==4) {
  164. wrong = wrong+1;
  165. System.out.println("You picked Green and the computer had picked Yellow! (Wrong)");
  166. }
  167. }
  168. if ("Blue".equals(B)) {
  169. num = (int) (Math.random()*4+1);
  170. if (num==1) {
  171. wrong = wrong+1;
  172. System.out.println("You picked Blue and the computer had picked Red! (Wrong)");
  173. }
  174. if (num==2) {
  175. wrong = wrong+1;
  176. System.out.println("You picked Blue and the computer had picked Green! (Wrong)");
  177. }
  178. if (num==3) {
  179. right = right+1;
  180. System.out.println("You picked Blue and the computer had also picked Blue! (Right)");
  181. }
  182. if (num==4) {
  183. wrong = wrong+1;
  184. System.out.println("You picked Blue and the computer had picked Yellow! (Wrong)");
  185. }
  186. }
  187. if ("Yellow".equals(B)) {
  188. num = (int) (Math.random()*4+1);
  189. if (num==1) {
  190. wrong = wrong+1;
  191. System.out.println("You picked Yellow and the computer had picked Red! (Wrong)");
  192. }
  193. if (num==2) {
  194. wrong = wrong+1;
  195. System.out.println("You picked Yellow and the computer had picked Green! (Wrong)");
  196. }
  197. if (num==3) {
  198. wrong = wrong+1;
  199. System.out.println("You picked Yellow and the computer had picked Blue! (Wrong)");
  200. }
  201. if (num==4) {
  202. right = right+1;
  203. System.out.println("You picked Yellow and the computer had also picked Yellow! (Right)");
  204. }
  205. }
  206. if ("Red".equals(G)) {
  207. num = (int) (Math.random()*4+1);
  208. if (num==1) {
  209. right = right+1;
  210. System.out.println("You picked Red and the computer had also picked Red! (Right)"
  211. + "\nRight - " + right + "\nWrong - " + wrong);
  212. }
  213. if (num==2) {
  214. wrong = wrong+1;
  215. System.out.println("You picked Red and the computer had picked Green! (Wrong)"
  216. + "\nRight - " + right + "\nWrong - " + wrong);
  217. }
  218. if (num==3) {
  219. wrong = wrong+1;
  220. System.out.println("You picked Red and the computer had picked Blue! (Wrong)"
  221. + "\nRight - " + right + "\nWrong - " + wrong);
  222. }
  223. if (num==4) {
  224. wrong = wrong+1;
  225. System.out.println("You picked Red and the computer had picked Yellow! (Wrong)"
  226. + "\nRight - " + right + "\nWrong - " + wrong);
  227. }
  228. }
  229. if ("Green".equals(G)) {
  230. num = (int) (Math.random()*4+1);
  231. if (num==1) {
  232. wrong = wrong+1;
  233. System.out.println("You picked Green and the computer had picked Red! (Wrong)"
  234. + "\nRight - " + right + "\nWrong - " + wrong);
  235. }
  236. if (num==2) {
  237. right = right+1;
  238. System.out.println("You picked Green and the computer had also picked Green! (Right)"
  239. + "\nRight - " + right + "\nWrong - " + wrong);
  240. }
  241. if (num==3) {
  242. wrong = wrong+1;
  243. System.out.println("You picked Green and the computer had picked Blue! (Wrong)"
  244. + "\nRight - " + right + "\nWrong - " + wrong);
  245. }
  246. if (num==4) {
  247. wrong = wrong+1;
  248. System.out.println("You picked Green and the computer had picked Yellow! (Wrong)"
  249. + "\nRight - " + right + "\nWrong - " + wrong);
  250. }
  251. }
  252. if ("Blue".equals(G)) {
  253. num = (int) (Math.random()*4+1);
  254. if (num==1) {
  255. wrong = wrong+1;
  256. System.out.println("You picked Blue and the computer had picked Red! (Wrong)"
  257. + "\nRight - " + right + "\nWrong - " + wrong);
  258. }
  259. if (num==2) {
  260. wrong = wrong+1;
  261. System.out.println("You picked Blue and the computer had picked Green! (Wrong)"
  262. + "\nRight - " + right + "\nWrong - " + wrong);
  263. }
  264. if (num==3) {
  265. right = right+1;
  266. System.out.println("You picked Blue and the computer had also picked Blue! (Right)"
  267. + "\nRight - " + right + "\nWrong - " + wrong);
  268. }
  269. if (num==4) {
  270. wrong = wrong+1;
  271. System.out.println("You picked Blue and the computer had picked Yellow! (Wrong)"
  272. + "\nRight - " + right + "\nWrong - " + wrong);
  273. }
  274. }
  275. if ("Yellow".equals(G)) {
  276. num = (int) (Math.random()*4+1);
  277. if (num==1) {
  278. wrong = wrong+1;
  279. System.out.println("You picked Yellow and the computer had picked Red! (Wrong)"
  280. + "\nRight - " + right + "\nWrong - " + wrong);
  281. }
  282. if (num==2) {
  283. wrong = wrong+1;
  284. System.out.println("You picked Yellow and the computer had picked Green! (Wrong)"
  285. + "\nRight - " + right + "\nWrong - " + wrong);
  286. }
  287. if (num==3) {
  288. wrong = wrong+1;
  289. System.out.println("You picked Yellow and the computer had picked Blue! (Wrong)"
  290. + "\nRight - " + right + "\nWrong - " + wrong);
  291. }
  292. if (num==4) {
  293. right = right+1;
  294. System.out.println("You picked Yellow and the computer had also picked Yellow! (Right)"
  295. + "\nRight - " + right + "\nWrong - " + wrong);
  296. }
  297. }
  298. Object[] options = {"Yes",
  299. "No"};
  300. a = JOptionPane.showConfirmDialog(null,
  301. "Would you like to play again?",
  302. "A question",
  303. JOptionPane.YES_NO_OPTION);
  304. if (a == JOptionPane.NO_OPTION) {
  305. System.out.println("You have opted to not play again. Have a nice day.");
  306. System.exit(0);
  307. }
  308.  
  309. }
  310. }
  311. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement