Advertisement
rig26

game

Nov 17th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 138.74 KB | None | 0 0
  1. package TicTacToe;
  2.  
  3. import javax.swing.*;
  4. import javax.swing.border.Border;
  5. import java.awt.*;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.event.ActionListener;
  8. import java.util.Arrays;
  9. import java.util.Random;
  10.  
  11. public class TicTacToe {
  12. private static JButton Easy, Medium, Hard;
  13. private static String StartGame = "X";
  14. private static int xCount = 0;
  15. private static int oCount = 0;
  16. private static int buttonUsed [] = {0,0,0,0,0,0,0,0,0};
  17. private static JButton t1,t2,t3,t4,t5,t6,t7,t8,t9;
  18. private static ImageIcon delete,circle,deletegrey,circlegrey;
  19. private static JLabel OScore, XScore, XLR, OLR,DLR;
  20. private static int drawScore = 0;
  21. private static int XLife = 3;
  22. private static int OLife = 3;
  23. private static int random;
  24. private static String difficulty;
  25. private static int contain;
  26. private static JFrame MainFrame, PlayFrame;
  27.  
  28.  
  29. public static void main(String[] args) {
  30. Color PaleWhite = Color.decode("#FDFDFD");
  31. Border black = BorderFactory.createLineBorder(PaleWhite,1);
  32. MainFrame = new JFrame("TicTacToe");
  33. JPanel MainPanel = new JPanel(null);
  34. JPanel ControlPanel = new JPanel(null);
  35. JPanel DifficultyPanel = new JPanel(null);
  36. JPanel PlayerAi = new JPanel(null);
  37. JLabel TicTacToeLogo = new JLabel(new ImageIcon("pictures\\Logo.png"));
  38. JButton PlayGame = new JButton("PLAY GAME");
  39. JButton Exit = new JButton("EXIT");
  40. Easy = new JButton("EASY");
  41. Medium = new JButton("MEDIUM");
  42. Hard = new JButton("HARD");
  43. JButton Cancel = new JButton("CANCEL");
  44. JButton AI = new JButton("AGAINST COMPUTER");
  45. JButton TwoPlayer = new JButton("TWO PLAYER");
  46. random = 1 + (int)(Math.random() *((3-1) + 1));
  47.  
  48.  
  49. //Another One
  50. PlayFrame = new JFrame("TicTacToe");
  51. JPanel PlayPanel = new JPanel(null);
  52. JPanel TicTacPanel = new JPanel(null);
  53. JLabel TicTacLabel = new JLabel(new ImageIcon("pictures\\Logo.png"));
  54. t1 = new JButton("<html><div align = Left width = 100px></html>");
  55. t2 = new JButton("<html><div align = Left width = 100px></html>");
  56. t3 = new JButton("<html><div align = Left width = 100px></html>");
  57. t4 = new JButton("<html><div align = Left width = 100px></html>");
  58. t5 = new JButton("<html><div align = Left width = 100px></html>");
  59. t6 = new JButton("<html><div align = Left width = 100px></html>");
  60. t7 = new JButton("<html><div align = Left width = 100px></html>");
  61. t8 = new JButton("<html><div align = Left width = 100px></html>");
  62. t9 = new JButton("<html><div align = Left width = 100px></html>");
  63. delete = new ImageIcon("pictures\\d.png");
  64. circle = new ImageIcon("pictures\\c.png");
  65. deletegrey = new ImageIcon("pictures\\dgrey.png");
  66. circlegrey = new ImageIcon("pictures\\cgrey.png");
  67. JLabel PlayerX = new JLabel("Player X");
  68. JLabel PlayerO = new JLabel("Player O");
  69. JLabel Score = new JLabel("Score");
  70. JLabel LifeRemaining = new JLabel("Life Remaining");
  71. JLabel draw = new JLabel("Draw Match");
  72. XScore = new JLabel();
  73. OScore = new JLabel();
  74. XLR = new JLabel(String.valueOf(XLife));
  75. OLR = new JLabel(String.valueOf(OLife));
  76. DLR = new JLabel();
  77.  
  78. XScore.setHorizontalAlignment(SwingConstants.CENTER);
  79. OScore.setHorizontalAlignment(SwingConstants.CENTER);
  80. OLR.setHorizontalAlignment(SwingConstants.CENTER);
  81. XLR.setHorizontalAlignment(SwingConstants.CENTER);
  82. DLR.setHorizontalAlignment(SwingConstants.CENTER);
  83.  
  84.  
  85.  
  86.  
  87.  
  88. //SetBounds
  89. //Panels
  90. //
  91. DLR.setBounds(125,510,50,50);
  92. draw.setBounds(15,510,80,50);
  93. Score.setBounds(15,500,80,50);
  94. OLR.setBounds(210,430,50,50);
  95. XLR.setBounds(125,430,50,50);
  96. OScore.setBounds(210,350,50,50);
  97. XScore.setBounds(125,350,50,50);
  98. PlayerX.setBounds(125,280,70,50);
  99. PlayerO.setBounds(205,280,70,50);
  100. Score.setBounds(15,350,80,50);
  101. LifeRemaining.setBounds(15,430,100,50);
  102. t1.setBounds(0,0,180,190);
  103. t2.setBounds(180,0,180,190);
  104. t3.setBounds(360,0,180,190);
  105. t4.setBounds(0,190,180,190);
  106. t5.setBounds(180,190,180,190);
  107. t6.setBounds(360,190,180,190);
  108. t7.setBounds(0,380,180,190);
  109. t8.setBounds(180,380,180,190);
  110. t9.setBounds(360,380,180,190);
  111.  
  112.  
  113. TicTacPanel.setBounds(300,50,540,570);
  114. TicTacLabel.setBounds(50,0,200,150);
  115. PlayPanel.setBounds(0,0,895,695);
  116. //
  117. MainPanel.setBounds(0,0,500,590);
  118. TicTacToeLogo.setBounds(147,10,200,150);
  119. ControlPanel.setBounds(73,150,350,350);
  120. DifficultyPanel.setBounds(73,150,350,350);
  121. PlayerAi.setBounds(73,150,350,350);
  122. //Buttons
  123. //
  124.  
  125. //
  126. PlayGame.setBounds(75,90,200,50);
  127. Exit.setBounds(75,200,200,50);
  128.  
  129. Easy.setBounds(75,40,200,50);
  130. Medium.setBounds(75,110,200,50);
  131. Hard.setBounds(75,180,200,50);
  132. Cancel.setBounds(75,270,200,50);
  133.  
  134. AI.setBounds(75,90,200,50);
  135. TwoPlayer.setBounds(75,200,200,50);
  136.  
  137.  
  138.  
  139. /*------------DESIGNS-----------------------------*/
  140. //Panel
  141. //
  142.  
  143. TicTacPanel.setOpaque(false);
  144. TicTacPanel.getBackground();
  145. PlayPanel.setBackground(Color.decode("#1D1D1D"));
  146. //
  147. MainPanel.setBackground(Color.decode("#1D1D1D"));
  148. ControlPanel.setOpaque(false);
  149. ControlPanel.getBackground();
  150. ControlPanel.setBorder(BorderFactory.createLineBorder(PaleWhite,3,true));
  151. DifficultyPanel.setOpaque(false);
  152. DifficultyPanel.getBackground();
  153. DifficultyPanel.setBorder(BorderFactory.createLineBorder(PaleWhite,3,true));
  154. PlayerAi.setOpaque(false);
  155. PlayerAi.getBackground();
  156. PlayerAi.setBorder(BorderFactory.createLineBorder(PaleWhite,3,true));
  157. //Buttons
  158. PlayGame.setOpaque(false);
  159. PlayGame.getBackground();
  160. PlayGame.setContentAreaFilled(false);
  161. PlayGame.setForeground(PaleWhite);
  162. PlayGame.setFocusPainted(false);
  163. PlayGame.setBorder(BorderFactory.createLineBorder(PaleWhite,3,true));
  164. PlayGame.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,12));
  165. Exit.setOpaque(false);
  166. Exit.getBackground();
  167. Exit.setContentAreaFilled(false);
  168. Exit.setForeground(PaleWhite);
  169. Exit.setFocusPainted(false);
  170. Exit.setBorder(BorderFactory.createLineBorder(PaleWhite,3,true));
  171. Exit.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,12));
  172.  
  173. Easy.setOpaque(false);
  174. Easy.getBackground();
  175. Easy.setContentAreaFilled(false);
  176. Easy.setForeground(PaleWhite);
  177. Easy.setFocusPainted(false);
  178. Easy.setBorder(BorderFactory.createLineBorder(PaleWhite,3,true));
  179. Easy.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,12));
  180. Medium.setOpaque(false);
  181. Medium.getBackground();
  182. Medium.setContentAreaFilled(false);
  183. Medium.setForeground(PaleWhite);
  184. Medium.setFocusPainted(false);
  185. Medium.setBorder(BorderFactory.createLineBorder(PaleWhite,3,true));
  186. Medium.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,12));
  187. Hard.setOpaque(false);
  188. Hard.getBackground();
  189. Hard.setContentAreaFilled(false);
  190. Hard.setForeground(PaleWhite);
  191. Hard.setFocusPainted(false);
  192. Hard.setBorder(BorderFactory.createLineBorder(PaleWhite,3,true));
  193. Hard.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,12));
  194. Cancel.setOpaque(false);
  195. Cancel.getBackground();
  196. Cancel.setContentAreaFilled(false);
  197. Cancel.setForeground(PaleWhite);
  198. Cancel.setFocusPainted(false);
  199. Cancel.setBorder(BorderFactory.createLineBorder(PaleWhite,3,true));
  200. Cancel.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,12));
  201.  
  202. AI.setOpaque(false);
  203. AI.getBackground();
  204. AI.setContentAreaFilled(false);
  205. AI.setForeground(PaleWhite);
  206. AI.setFocusPainted(false);
  207. AI.setBorder(BorderFactory.createLineBorder(PaleWhite,3,true));
  208. AI.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,12));
  209.  
  210. TwoPlayer.setOpaque(false);
  211. TwoPlayer.getBackground();
  212. TwoPlayer.setContentAreaFilled(false);
  213. TwoPlayer.setForeground(PaleWhite);
  214. TwoPlayer.setFocusPainted(false);
  215. TwoPlayer.setBorder(BorderFactory.createLineBorder(PaleWhite,3,true));
  216. TwoPlayer.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,12));
  217.  
  218.  
  219.  
  220. t1.setOpaque(false);
  221. t1.setBackground(MainPanel.getBackground());
  222. t1.setContentAreaFilled(false);
  223. t1.setForeground(PaleWhite);
  224. t1.setFocusPainted(false);
  225. t1.setBorder(BorderFactory.createMatteBorder(0,0,3,3,PaleWhite));
  226. t1.setIconTextGap(-30);
  227.  
  228. t2.setOpaque(false);
  229. t2.setBackground(MainPanel.getBackground());
  230. t2.setContentAreaFilled(false);
  231. t2.setForeground(PaleWhite);
  232. t2.setFocusPainted(false);
  233. t2.setBorder(BorderFactory.createMatteBorder(0,3,3,3,PaleWhite));
  234. t2.setIconTextGap(-30);
  235.  
  236. t3.setOpaque(false);
  237. t3.setBackground(MainPanel.getBackground());
  238. t3.setContentAreaFilled(false);
  239. t3.setForeground(PaleWhite);
  240. t3.setFocusPainted(false);
  241. t3.setBorder(BorderFactory.createMatteBorder(0,3,3,0,PaleWhite));
  242. t3.setIconTextGap(-30);
  243.  
  244. t4.setOpaque(false);
  245. t4.setBackground(MainPanel.getBackground());
  246. t4.setContentAreaFilled(false);
  247. t4.setForeground(PaleWhite);
  248. t4.setFocusPainted(false);
  249. t4.setBorder(BorderFactory.createMatteBorder(3,0,3,3,PaleWhite));
  250. t4.setIconTextGap(-30);
  251.  
  252. t5.setOpaque(false);
  253. t5.setBackground(MainPanel.getBackground());
  254. t5.setContentAreaFilled(false);
  255. t5.setForeground(PaleWhite);
  256. t5.setFocusPainted(false);
  257. t5.setBorder(BorderFactory.createMatteBorder(3,3,3,3,PaleWhite));
  258. t5.setIconTextGap(-30);
  259.  
  260. t6.setOpaque(false);
  261. t6.setBackground(MainPanel.getBackground());
  262. t6.setContentAreaFilled(false);
  263. t6.setForeground(PaleWhite);
  264. t6.setFocusPainted(false);
  265. t6.setBorder(BorderFactory.createMatteBorder(3,3,3,0,PaleWhite));
  266. t6.setIconTextGap(-30);
  267.  
  268. t7.setOpaque(false);
  269. t7.setBackground(MainPanel.getBackground());
  270. t7.setContentAreaFilled(false);
  271. t7.setForeground(PaleWhite);
  272. t7.setFocusPainted(false);
  273. t7.setBorder(BorderFactory.createMatteBorder(3,0,0,3,PaleWhite));
  274. t7.setIconTextGap(-30);
  275.  
  276. t8.setOpaque(false);
  277. t8.setBackground(MainPanel.getBackground());
  278. t8.setContentAreaFilled(false);
  279. t8.setForeground(PaleWhite);
  280. t8.setFocusPainted(false);
  281. t8.setBorder(BorderFactory.createMatteBorder(3,3,0,3,PaleWhite));
  282. t8.setIconTextGap(-30);
  283.  
  284. t9.setOpaque(false);
  285. t9.setBackground(MainPanel.getBackground());
  286. t9.setContentAreaFilled(false);
  287. t9.setForeground(PaleWhite);
  288. t9.setFocusPainted(false);
  289. t9.setBorder(BorderFactory.createMatteBorder(3,3,0,0,PaleWhite));
  290. t9.setIconTextGap(-30);
  291.  
  292. LifeRemaining.setOpaque(false);
  293. LifeRemaining.setForeground(PaleWhite);
  294. LifeRemaining.setBackground(PlayPanel.getBackground());
  295. LifeRemaining.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,15));
  296.  
  297.  
  298. PlayerX.setOpaque(false);
  299. PlayerX.setForeground(PaleWhite);
  300. PlayerX.setBackground(PlayPanel.getBackground());
  301. PlayerX.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,15));
  302.  
  303.  
  304. PlayerO.setOpaque(false);
  305. PlayerO.setForeground(PaleWhite);
  306. PlayerO.setBackground(PlayPanel.getBackground());
  307. PlayerO.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,15));
  308.  
  309. Score.setOpaque(false);
  310. Score.setForeground(PaleWhite);
  311. Score.setBackground(PlayPanel.getBackground());
  312. Score.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,15));
  313.  
  314. XScore.setOpaque(false);
  315. XScore.setForeground(PaleWhite);
  316. XScore.setBackground(PlayPanel.getBackground());
  317. XScore.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,15));
  318.  
  319.  
  320. OScore.setOpaque(false);
  321. OScore.setForeground(PaleWhite);
  322. OScore.setBackground(PlayPanel.getBackground());
  323. OScore.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,15));
  324.  
  325.  
  326. XLR.setOpaque(false);
  327. XLR.setForeground(PaleWhite);
  328. XLR.setBackground(PlayPanel.getBackground());
  329. XLR.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,15));
  330.  
  331.  
  332. OLR.setOpaque(false);
  333. OLR.setForeground(PaleWhite);
  334. OLR.setBackground(PlayPanel.getBackground());
  335. OLR.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,15));
  336.  
  337.  
  338. draw.setOpaque(false);
  339. draw.setForeground(PaleWhite);
  340. draw.setBackground(PlayPanel.getBackground());
  341. draw.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,15));
  342.  
  343. DLR.setOpaque(false);
  344. DLR.setForeground(PaleWhite);
  345. DLR.setBackground(PlayPanel.getBackground());
  346. DLR.setFont(new Font("Lato Bold",Font.TRUETYPE_FONT,15));
  347.  
  348.  
  349.  
  350.  
  351. //ADD
  352. PlayPanel.add(draw);
  353. PlayPanel.add(DLR);
  354. PlayPanel.add(LifeRemaining);
  355. PlayPanel.add(Score);
  356. PlayPanel.add(PlayerO);
  357. PlayPanel.add(PlayerX);
  358. PlayPanel.add(XScore);
  359. PlayPanel.add(OScore);
  360. PlayPanel.add(XLR);
  361. PlayPanel.add(OLR);
  362. TicTacPanel.add(t1);
  363. TicTacPanel.add(t2);
  364. TicTacPanel.add(t3);
  365. TicTacPanel.add(t4);
  366. TicTacPanel.add(t5);
  367. TicTacPanel.add(t6);
  368. TicTacPanel.add(t7);
  369. TicTacPanel.add(t8);
  370. TicTacPanel.add(t9);
  371. PlayPanel.add(TicTacPanel);
  372. PlayPanel.add(TicTacLabel);
  373. PlayFrame.add(PlayPanel);
  374. //
  375. PlayerAi.add(TwoPlayer);
  376. PlayerAi.add(AI);
  377. DifficultyPanel.add(Cancel);
  378. DifficultyPanel.add(Easy);
  379. DifficultyPanel.add(Medium);
  380. DifficultyPanel.add(Hard);
  381. ControlPanel.add(Exit);
  382. ControlPanel.add(PlayGame);
  383. MainPanel.add(PlayerAi);
  384. MainPanel.add(DifficultyPanel);
  385. MainPanel.add(ControlPanel);
  386. MainPanel.add(TicTacToeLogo);
  387. MainFrame.add(MainPanel);
  388. //
  389.  
  390. //
  391. //
  392. TicTacPanel.setVisible(true);
  393. PlayPanel.setVisible(true);
  394. //
  395. PlayerAi.setVisible(false);
  396. DifficultyPanel.setVisible(false);
  397. ControlPanel.setVisible(true);
  398. MainPanel.setVisible(true);
  399.  
  400.  
  401.  
  402. /*-------------------------------ACTION LISTENERS----------------------------------------*/
  403. PlayGame.addActionListener(new ActionListener() {
  404. @Override
  405. public void actionPerformed(ActionEvent e) {
  406. ControlPanel.setVisible(false);
  407. DifficultyPanel.setVisible(true);
  408.  
  409. }
  410. });
  411.  
  412. Exit.addActionListener(new ActionListener() {
  413. @Override
  414. public void actionPerformed(ActionEvent e) {
  415. System.exit(0);
  416. }
  417. });
  418.  
  419. Cancel.addActionListener(new ActionListener() {
  420. @Override
  421. public void actionPerformed(ActionEvent e) {
  422. ControlPanel.setVisible(true);
  423. DifficultyPanel.setVisible(false);
  424. }
  425. });
  426.  
  427. Easy.addActionListener(new ActionListener() {
  428. @Override
  429. public void actionPerformed(ActionEvent e) {
  430. difficulty = Easy.getText();
  431. MainFrame.setVisible(false);
  432. PlayFrame.setVisible(true);
  433. }
  434. });
  435.  
  436. Medium.addActionListener(new ActionListener() {
  437. @Override
  438. public void actionPerformed(ActionEvent e) {
  439. difficulty = Medium.getText();
  440. MainFrame.setVisible(false);
  441. PlayFrame.setVisible(true);
  442. }
  443. });
  444.  
  445. Hard.addActionListener(new ActionListener() {
  446. @Override
  447. public void actionPerformed(ActionEvent e) {
  448. difficulty = Hard.getText();
  449. MainFrame.setVisible(false);
  450. PlayFrame.setVisible(true);
  451. }
  452. });
  453.  
  454.  
  455. t1.addActionListener(new ActionListener() {
  456. @Override
  457. public void actionPerformed(ActionEvent e) {
  458. if (buttonUsed[0] == 0){
  459. t1.setText(StartGame);
  460. if (t1.getText().equals("X")){
  461. t1.setIcon(delete);
  462. }else {
  463. t1.setIcon(circle);
  464. }
  465. if (StartGame.equalsIgnoreCase("X")){
  466. t1.setForeground(MainPanel.getBackground());
  467. buttonUsed [0] = 1;
  468.  
  469.  
  470. }else {
  471. t1.setForeground(MainPanel.getBackground());
  472. buttonUsed [0] = 1;
  473. }
  474. choosePlayer();
  475. winningGame();
  476. Winner();
  477. }else {
  478. JOptionPane.showMessageDialog(null,"It have been used!","",JOptionPane.WARNING_MESSAGE);
  479. }
  480.  
  481. }
  482. });
  483.  
  484. t2.addActionListener(new ActionListener() {
  485. @Override
  486. public void actionPerformed(ActionEvent e) {
  487. if (buttonUsed[1] == 0){
  488. t2.setText(StartGame);
  489. if (t2.getText().equals("X")){
  490. t2.setIcon(delete);
  491. }else {
  492. t2.setIcon(circle);
  493. }
  494. if (StartGame.equalsIgnoreCase("X")){
  495. t2.setForeground(MainPanel.getBackground());
  496. buttonUsed[1] = 1;
  497.  
  498. }else {
  499. t2.setForeground(MainPanel.getBackground());
  500. buttonUsed[1] = 1;
  501. }
  502. choosePlayer();
  503. winningGame();
  504. Winner();
  505. }else {
  506. JOptionPane.showMessageDialog(null,"It have been used!","",JOptionPane.WARNING_MESSAGE);
  507.  
  508. }
  509. }
  510. });
  511.  
  512. t3.addActionListener(new ActionListener() {
  513. @Override
  514. public void actionPerformed(ActionEvent e) {
  515. if (buttonUsed[2] == 0){
  516. t3.setText(StartGame);
  517. if (t3.getText().equals("X")){
  518. t3.setIcon(delete);
  519. }else {
  520. t3.setIcon(circle);
  521. }
  522. if (StartGame.equalsIgnoreCase("X")){
  523. t3.setForeground(MainPanel.getBackground());
  524. buttonUsed[2] = 1;
  525. }else {
  526. t3.setForeground(MainPanel.getBackground());
  527. buttonUsed[2] = 1;
  528. }
  529. choosePlayer();
  530. winningGame();
  531. Winner();
  532. }else {
  533. JOptionPane.showMessageDialog(null,"It have been used!","",JOptionPane.WARNING_MESSAGE);
  534. }
  535. }
  536. });
  537.  
  538. t4.addActionListener(new ActionListener() {
  539. @Override
  540. public void actionPerformed(ActionEvent e) {
  541. if (buttonUsed[3] == 0){
  542. t4.setText(StartGame);
  543. if (t4.getText().equals("X")){
  544. t4.setIcon(delete);
  545. }else {
  546. t4.setIcon(circle);
  547. }
  548. if (StartGame.equalsIgnoreCase("X")){
  549. t4.setForeground(MainPanel.getBackground());
  550. buttonUsed [3] = 1;
  551. }else {
  552. t4.setForeground(MainPanel.getBackground());
  553. buttonUsed [3] = 1;
  554. }
  555. choosePlayer();
  556. winningGame();
  557. Winner();
  558. }else {
  559. JOptionPane.showMessageDialog(null,"It have been used!","",JOptionPane.WARNING_MESSAGE);
  560.  
  561. }
  562. }
  563. });
  564.  
  565. t5.addActionListener(new ActionListener() {
  566. @Override
  567. public void actionPerformed(ActionEvent e) {
  568. if (buttonUsed[4] == 0){
  569. t5.setText(StartGame);
  570. if (t5.getText().equals("X")){
  571. t5.setIcon(delete);
  572. }else {
  573. t5.setIcon(circle);
  574. }
  575. if (StartGame.equalsIgnoreCase("X")){
  576. t5.setForeground(MainPanel.getBackground());
  577. buttonUsed[4] = 1;
  578. }else {
  579. t5.setForeground(MainPanel.getBackground());
  580. buttonUsed[4] = 1;
  581. }
  582. choosePlayer();
  583. winningGame();
  584. Winner();
  585. }else {
  586. JOptionPane.showMessageDialog(null,"It have been used!","",JOptionPane.WARNING_MESSAGE);
  587.  
  588. }
  589. }
  590. });
  591.  
  592. t6.addActionListener(new ActionListener() {
  593. @Override
  594. public void actionPerformed(ActionEvent e) {
  595. if (buttonUsed[5] == 0){
  596. t6.setText(StartGame);
  597. if (t6.getText().equals("X")){
  598. t6.setIcon(delete);
  599. }else {
  600. t6.setIcon(circle);
  601. }
  602. if (StartGame.equalsIgnoreCase("X")){
  603. t6.setForeground(MainPanel.getBackground());
  604. buttonUsed[5] = 1;
  605. }else {
  606. t6.setForeground(MainPanel.getBackground());
  607. buttonUsed[5] = 1;
  608. }
  609. choosePlayer();
  610. winningGame();
  611. Winner();
  612. }else {
  613. JOptionPane.showMessageDialog(null,"It have been used!","",JOptionPane.WARNING_MESSAGE);
  614. }
  615. }
  616. });
  617.  
  618. t7.addActionListener(new ActionListener() {
  619. @Override
  620. public void actionPerformed(ActionEvent e) {
  621. if (buttonUsed[6] == 0) {
  622. t7.setText(StartGame);
  623. if (t7.getText().equals("X")){
  624. t7.setIcon(delete);
  625. }else {
  626. t7.setIcon(circle);
  627. }
  628. if (StartGame.equalsIgnoreCase("X")){
  629. t7.setForeground(MainPanel.getBackground());
  630. buttonUsed[6] = 1;
  631. }else {
  632. t7.setForeground(MainPanel.getBackground());
  633. buttonUsed[6] = 1;
  634. }
  635. choosePlayer();
  636. winningGame();
  637. Winner();
  638. }else {
  639. JOptionPane.showMessageDialog(null,"It have been used!","",JOptionPane.WARNING_MESSAGE);
  640. }
  641. }
  642. });
  643.  
  644. t8.addActionListener(new ActionListener() {
  645. @Override
  646. public void actionPerformed(ActionEvent e) {
  647. if (buttonUsed [7] == 0){
  648. t8.setText(StartGame);
  649. if (t8.getText().equals("X")){
  650. t8.setIcon(delete);
  651. }else {
  652. t8.setIcon(circle);
  653. }
  654. if (StartGame.equalsIgnoreCase("X")){
  655. t8.setForeground(MainPanel.getBackground());
  656. buttonUsed [7] = 1;
  657. }else {
  658. t8.setForeground(MainPanel.getBackground());
  659. buttonUsed [7] = 1;
  660. }
  661. choosePlayer();
  662. winningGame();
  663. Winner();
  664. }else {
  665. JOptionPane.showMessageDialog(null,"It have been used!","",JOptionPane.WARNING_MESSAGE);
  666. }
  667. }
  668. });
  669.  
  670. t9.addActionListener(new ActionListener() {
  671. @Override
  672. public void actionPerformed(ActionEvent e) {
  673. if (buttonUsed[8] == 0){
  674. t9.setText(StartGame);
  675. if (t9.getText().equals("X")){
  676. t9.setIcon(delete);
  677. }else {
  678. t9.setIcon(circle);
  679. }
  680. if (StartGame.equalsIgnoreCase("X")){
  681. t9.setForeground(MainPanel.getBackground());
  682. buttonUsed[8] = 1;
  683. }else {
  684. t9.setForeground(MainPanel.getBackground());
  685. buttonUsed[8] = 1;
  686. }
  687. choosePlayer();
  688. winningGame();
  689. Winner();
  690. }else {
  691. JOptionPane.showMessageDialog(null,"It have been used!","",JOptionPane.WARNING_MESSAGE);
  692. }
  693. }
  694. });
  695.  
  696.  
  697.  
  698. //
  699. if (XLife == 0 ){
  700. JOptionPane.showMessageDialog(null,"Game Over! , Player O Win!");
  701. }
  702. if (OLife == 0 ){
  703. JOptionPane.showMessageDialog(null,"Game Over! , Player X Win!");
  704. }
  705.  
  706. PlayFrame.setSize(900,700);
  707. PlayFrame.setLocationRelativeTo(null);
  708. PlayFrame.setResizable(false);
  709. PlayFrame.setDefaultCloseOperation(MainFrame.EXIT_ON_CLOSE);
  710. PlayFrame.setLayout(null);
  711. PlayFrame.setVisible(false);
  712.  
  713. MainFrame.setSize(500,600);
  714. MainFrame.setLocationRelativeTo(null);
  715. MainFrame.setResizable(false);
  716. MainFrame.setDefaultCloseOperation(MainFrame.EXIT_ON_CLOSE);
  717. MainFrame.setLayout(null);
  718. MainFrame.setVisible(true);
  719. }
  720.  
  721. private static void questions(){
  722. xPlay();
  723. oPlay();
  724.  
  725. }
  726. private static void Winner(){
  727. if (xCount == 12){
  728. PlayFrame.setVisible(false);
  729. PlayFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  730. JOptionPane.showMessageDialog(null,"Player X is the Winner! ");
  731.  
  732. }
  733. if (oCount == 12){
  734. PlayFrame.setVisible(false);
  735. PlayFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  736. JOptionPane.showMessageDialog(null,"Player O is the Winner! ");
  737.  
  738. }
  739. }
  740. private static void xPlay(){
  741. if (xCount == 3){
  742. if (difficulty.equalsIgnoreCase("Easy")){
  743. xEasyQuestions();
  744. }else if (difficulty.equalsIgnoreCase("Medium")){
  745. xMediumQuestions();
  746. }else {
  747. xHardQuestions();
  748. }
  749. }
  750.  
  751. if (xCount == 6){
  752. if (difficulty.equalsIgnoreCase("Easy")){
  753. xEasyQuestions();
  754. }else if (difficulty.equalsIgnoreCase("Medium")){
  755. xMediumQuestions();
  756. }else {
  757. xHardQuestions();
  758. }
  759. }
  760.  
  761. if (xCount == 9){
  762. if (difficulty.equalsIgnoreCase("Easy")){
  763. xEasyQuestions();
  764. }else if (difficulty.equalsIgnoreCase("Medium")){
  765. xMediumQuestions();
  766. }else {
  767. xHardQuestions();
  768. }
  769. }
  770.  
  771. if (Integer.parseInt(XLR.getText()) == 0){
  772. PlayFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  773. JOptionPane.showMessageDialog(null,"Game Over! Player O WIN! ");
  774. }
  775.  
  776.  
  777. }
  778.  
  779. private static void oPlay(){
  780. if (oCount == 3){
  781. if (difficulty.equalsIgnoreCase("Easy")){
  782. oEasyQuestions();
  783. }else if (difficulty.equalsIgnoreCase("Medium")){
  784. oMediumQuestions();
  785. }else {
  786. oHardQuestions();
  787. }
  788. }
  789.  
  790. if (oCount == 6){
  791. if (difficulty.equalsIgnoreCase("Easy")){
  792. oEasyQuestions();
  793. }else if (difficulty.equalsIgnoreCase("Medium")){
  794. oMediumQuestions();
  795. }else {
  796. oHardQuestions();
  797. }
  798. }
  799.  
  800. if (oCount == 9){
  801. if (difficulty.equalsIgnoreCase("Easy")) {
  802. oEasyQuestions();
  803. }else if (difficulty.equalsIgnoreCase("Medium")){
  804. oMediumQuestions();
  805. }else {
  806. oHardQuestions();
  807. }
  808. }
  809.  
  810. if (Integer.parseInt(OLR.getText()) == 0){
  811. PlayFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  812. JOptionPane.showMessageDialog(null,"Game Over! Player X WIN! ");
  813. }
  814.  
  815.  
  816. }
  817.  
  818. private static void xEasyQuestions(){
  819. String[] options = {"OK"};
  820. switch (random){
  821. case 1:
  822.  
  823. JPanel panel = new JPanel();
  824. JLabel lbl = new JLabel("1 + 1 = ");
  825. JTextField txt = new JTextField(10);
  826. panel.add(lbl);
  827. panel.add(txt);
  828. int selectedOption = JOptionPane.showOptionDialog(null, panel, "Question No. 1: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  829. if(selectedOption == 0)
  830. {
  831. if (Integer.parseInt(txt.getText()) == 2){
  832. XScore.setText(String.valueOf(xCount+=1));
  833. if (Integer.parseInt(XLR.getText()) == 5){
  834. XLR.setText(String.valueOf(XLife = 5));
  835. }else {
  836. XLR.setText(String.valueOf(XLife+=1));
  837. }
  838. random++;
  839. }else{
  840. XScore.setText(String.valueOf(xCount-=1));
  841. XLR.setText(String.valueOf(XLife-=1));
  842. random++;
  843. }
  844. }
  845. break;
  846. case 2:
  847. JPanel panel2 = new JPanel();
  848. JLabel lbl2 = new JLabel("(5 + 5) / 2 = ");
  849. JTextField txt2 = new JTextField(10);
  850. panel2.add(lbl2);
  851. panel2.add(txt2);
  852. int selectedOption2 = JOptionPane.showOptionDialog(null, panel2, "Question No. 2: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  853. if (selectedOption2 == 0){
  854. if (Integer.parseInt(txt2.getText()) == 5){
  855. XScore.setText(String.valueOf(xCount+=1));
  856. if (Integer.parseInt(XLR.getText()) == 5){
  857. XLR.setText(String.valueOf(XLife = 5));
  858. }else {
  859. XLR.setText(String.valueOf(XLife+=1));
  860. }
  861. random++;
  862. }else {
  863. XScore.setText(String.valueOf(xCount-=1));
  864. XLR.setText(String.valueOf(XLife-=1));
  865. random++;
  866. }
  867. }
  868. break;
  869. case 3:
  870. JPanel panel3 = new JPanel();
  871. JLabel lbl3 = new JLabel("2 + 5 = ");
  872. JTextField txt3 = new JTextField(10);
  873. panel3.add(lbl3);
  874. panel3.add(txt3);
  875. int selectedOption3 = JOptionPane.showOptionDialog(null, panel3, "Question No. 3: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  876. if (selectedOption3 == 0){
  877. if (Integer.parseInt(txt3.getText()) == 7){
  878. XScore.setText(String.valueOf(xCount+=1));
  879. if (Integer.parseInt(XLR.getText()) == 5){
  880. XLR.setText(String.valueOf(XLife = 5));
  881. }else {
  882. XLR.setText(String.valueOf(XLife+=1));
  883. }
  884. random++;
  885. }else {
  886. XScore.setText(String.valueOf(xCount-=1));
  887. XLR.setText(String.valueOf(XLife-=1));
  888. random++;
  889. }
  890.  
  891. }
  892. break;
  893. case 4:
  894. JPanel panel4 = new JPanel();
  895. JLabel lbl4 = new JLabel("10 + (50 * 5) - 6 = ");
  896. JTextField txt4 = new JTextField(10);
  897. panel4.add(lbl4);
  898. panel4.add(txt4);
  899. int selectedOption4 = JOptionPane.showOptionDialog(null, panel4, "Question No. 4: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  900. if (selectedOption4 == 0){
  901. if (Integer.parseInt(txt4.getText()) == 254){
  902. XScore.setText(String.valueOf(xCount+=1));
  903. if (Integer.parseInt(XLR.getText()) == 5){
  904. XLR.setText(String.valueOf(XLife = 5));
  905. }else {
  906. XLR.setText(String.valueOf(XLife+=1));
  907. }
  908. random++;
  909. }else {
  910. XScore.setText(String.valueOf(xCount-=1));
  911. XLR.setText(String.valueOf(XLife-=1));
  912. random++;
  913. }
  914. }
  915.  
  916. break;
  917. case 5:
  918. JPanel panel5 = new JPanel();
  919. JLabel lbl5 = new JLabel("100 * 5 + 10 = ");
  920. JTextField txt5 = new JTextField(10);
  921. panel5.add(lbl5);
  922. panel5.add(txt5);
  923. int selectedOption5 = JOptionPane.showOptionDialog(null, panel5, "Question No. 5: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  924. if (selectedOption5 == 0){
  925. if (Integer.parseInt(txt5.getText()) == 510){
  926. XScore.setText(String.valueOf(xCount+=1));
  927. if (Integer.parseInt(XLR.getText()) == 5){
  928. XLR.setText(String.valueOf(XLife = 5));
  929. }else {
  930. XLR.setText(String.valueOf(XLife+=1));
  931. }
  932. random++;
  933. }else {
  934. XScore.setText(String.valueOf(xCount-=1));
  935. XLR.setText(String.valueOf(XLife-=1));
  936. random++;
  937. }
  938. }
  939. break;
  940. case 6:
  941. JPanel panel6 = new JPanel();
  942. JLabel lbl6 = new JLabel("75 + 55 + 68 = ");
  943. JTextField txt6 = new JTextField(10);
  944. panel6.add(lbl6);
  945. panel6.add(txt6);
  946. int selectedOption6 = JOptionPane.showOptionDialog(null, panel6, "Question No. 6: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  947. if (selectedOption6 == 0){
  948. if (Integer.parseInt(txt6.getText()) == 198){
  949. XScore.setText(String.valueOf(xCount+=1));
  950. if (Integer.parseInt(XLR.getText()) == 5){
  951. XLR.setText(String.valueOf(XLife = 5));
  952. }else {
  953. XLR.setText(String.valueOf(XLife+=1));
  954. }
  955. random++;
  956. }else {
  957. XScore.setText(String.valueOf(xCount-=1));
  958. XLR.setText(String.valueOf(XLife-=1));
  959. random++;
  960. }
  961. }
  962.  
  963. break;
  964. case 7:
  965. JPanel panel7 = new JPanel();
  966. JLabel lbl7 = new JLabel("1500 + 700 + (-300) = ");
  967. JTextField txt7 = new JTextField(10);
  968. panel7.add(lbl7);
  969. panel7.add(txt7);
  970. int selectedOption7 = JOptionPane.showOptionDialog(null, panel7, "Question No. 7: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  971. if (selectedOption7 == 0){
  972. if (Integer.parseInt(txt7.getText()) == 1900){
  973. XScore.setText(String.valueOf(xCount+=1));
  974. if (Integer.parseInt(XLR.getText()) == 5){
  975. XLR.setText(String.valueOf(XLife = 5));
  976. }else {
  977. XLR.setText(String.valueOf(XLife+=1));
  978. }
  979. random++;
  980. }else {
  981. XScore.setText(String.valueOf(xCount-=1));
  982. XLR.setText(String.valueOf(XLife-=1));
  983. random++;
  984. }
  985. }
  986.  
  987. break;
  988. case 8:
  989. JPanel panel8 = new JPanel();
  990. JLabel lbl8 = new JLabel("900 + 800 + 500 = ");
  991. JTextField txt8 = new JTextField(10);
  992. panel8.add(lbl8);
  993. panel8.add(txt8);
  994. int selectedOption8 = JOptionPane.showOptionDialog(null, panel8, "Question No. 8: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  995. if (selectedOption8 == 0){
  996. if (Integer.parseInt(txt8.getText()) == 2200){
  997. XScore.setText(String.valueOf(xCount+=1));
  998. if (Integer.parseInt(XLR.getText()) == 5){
  999. XLR.setText(String.valueOf(XLife = 5));
  1000. }else {
  1001. XLR.setText(String.valueOf(XLife+=1));
  1002. }
  1003. random++;
  1004. }else {
  1005. XScore.setText(String.valueOf(xCount-=1));
  1006. XLR.setText(String.valueOf(XLife-=1));
  1007. random++;
  1008. }
  1009. }
  1010. break;
  1011. case 9:
  1012. JPanel panel9 = new JPanel();
  1013. JLabel lbl9 = new JLabel("-1 - 1 + 1 - 1 + 1 = ");
  1014. JTextField txt9 = new JTextField(10);
  1015. panel9.add(lbl9);
  1016. panel9.add(txt9);
  1017. int selectedOption9 = JOptionPane.showOptionDialog(null, panel9, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1018. if (selectedOption9 == 0){
  1019. if (Integer.parseInt(txt9.getText()) == -1){
  1020. XScore.setText(String.valueOf(xCount+=1));
  1021. if (Integer.parseInt(XLR.getText()) == 5){
  1022. XLR.setText(String.valueOf(XLife = 5));
  1023. }else {
  1024. XLR.setText(String.valueOf(XLife+=1));
  1025. }
  1026. random++;
  1027. }else {
  1028. XScore.setText(String.valueOf(xCount-=1));
  1029. XLR.setText(String.valueOf(XLife-=1));
  1030. random++;
  1031. }
  1032. }
  1033. break;
  1034. case 10:
  1035. JPanel panel10 = new JPanel();
  1036. JLabel lbl10 = new JLabel("800 + 700 =");
  1037. JTextField txt10 = new JTextField(10);
  1038. panel10.add(lbl10);
  1039. panel10.add(txt10);
  1040. int selectedOption10 = JOptionPane.showOptionDialog(null, panel10, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1041. if (selectedOption10 == 0){
  1042. if (Integer.parseInt(txt10.getText()) == 1500){
  1043. XScore.setText(String.valueOf(xCount+=1));
  1044. if (Integer.parseInt(XLR.getText()) == 5){
  1045. XLR.setText(String.valueOf(XLife = 5));
  1046. }else {
  1047. XLR.setText(String.valueOf(XLife+=1));
  1048. }
  1049. random++;
  1050. }else {
  1051. XScore.setText(String.valueOf(xCount-=1));
  1052. XLR.setText(String.valueOf(XLife-=1));
  1053. random++;
  1054. }
  1055. }
  1056. break;
  1057. case 11:
  1058. JPanel panel11 = new JPanel();
  1059. JLabel lbl11 = new JLabel("1900 * 700 / 5 = ");
  1060. JTextField txt11 = new JTextField(10);
  1061. panel11.add(lbl11);
  1062. panel11.add(txt11);
  1063. int selectedOption11 = JOptionPane.showOptionDialog(null, panel11, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1064. if (selectedOption11 == 0){
  1065. if (Integer.parseInt(txt11.getText()) == 266000){
  1066. XScore.setText(String.valueOf(xCount+=1));
  1067. if (Integer.parseInt(XLR.getText()) == 5){
  1068. XLR.setText(String.valueOf(XLife = 5));
  1069. }else {
  1070. XLR.setText(String.valueOf(XLife+=1));
  1071. }
  1072. random++;
  1073. }else {
  1074. XScore.setText(String.valueOf(xCount-=1));
  1075. XLR.setText(String.valueOf(XLife-=1));
  1076. random++;
  1077. }
  1078. }
  1079. break;
  1080. case 12:
  1081. JPanel panel12 = new JPanel();
  1082. JLabel lbl12 = new JLabel("580 + 780 = ");
  1083. JTextField txt12 = new JTextField(10);
  1084. panel12.add(lbl12);
  1085. panel12.add(txt12);
  1086. int selectedOption12 = JOptionPane.showOptionDialog(null, panel12, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1087. if (selectedOption12 == 0){
  1088. if (Integer.parseInt(txt12.getText()) == 1360){
  1089. XScore.setText(String.valueOf(xCount+=1));
  1090. if (Integer.parseInt(XLR.getText()) == 5){
  1091. XLR.setText(String.valueOf(XLife = 5));
  1092. }else {
  1093. XLR.setText(String.valueOf(XLife+=1));
  1094. }
  1095. random++;
  1096. }else {
  1097. XScore.setText(String.valueOf(xCount-=1));
  1098. XLR.setText(String.valueOf(XLife-=1));
  1099. random++;
  1100. }
  1101. }
  1102. break;
  1103. case 13:
  1104. JPanel panel13 = new JPanel();
  1105. JLabel lbl13 = new JLabel("500 - (-9) = ");
  1106. JTextField txt13 = new JTextField(10);
  1107. panel13.add(lbl13);
  1108. panel13.add(txt13);
  1109. int selectedOption13 = JOptionPane.showOptionDialog(null, panel13, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1110. if (selectedOption13 == 0){
  1111. if (Integer.parseInt(txt13.getText()) == 509){
  1112. XScore.setText(String.valueOf(xCount+=1));
  1113. if (Integer.parseInt(XLR.getText()) == 5){
  1114. XLR.setText(String.valueOf(XLife = 5));
  1115. }else {
  1116. XLR.setText(String.valueOf(XLife+=1));
  1117. }
  1118. random++;
  1119. }else {
  1120. XScore.setText(String.valueOf(xCount-=1));
  1121. XLR.setText(String.valueOf(XLife-=1));
  1122. random++;
  1123. }
  1124. }
  1125. break;
  1126.  
  1127. }
  1128. }
  1129.  
  1130. private static void oEasyQuestions(){
  1131. String[] options = {"OK"};
  1132. switch (random){
  1133. case 1:
  1134.  
  1135. JPanel panel = new JPanel();
  1136. JLabel lbl = new JLabel("1 + 1 = ");
  1137. JTextField txt = new JTextField(10);
  1138. panel.add(lbl);
  1139. panel.add(txt);
  1140. int selectedOption = JOptionPane.showOptionDialog(null, panel, "Question No. 1: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1141.  
  1142. if(selectedOption == 0)
  1143. {
  1144. if (Integer.parseInt(txt.getText()) == 2){
  1145. OScore.setText(String.valueOf(oCount+=1));
  1146. if (Integer.parseInt(OLR.getText()) == 5){
  1147. OLR.setText(String.valueOf(OLife = 5));
  1148. }else {
  1149. OLR.setText(String.valueOf(OLife+=1));
  1150. }
  1151. random++;
  1152. }else{
  1153. OScore.setText(String.valueOf(oCount-=1));
  1154. OLR.setText(String.valueOf(OLife-=1));
  1155. random++;
  1156. }
  1157. }
  1158. break;
  1159. case 2:
  1160. JPanel panel2 = new JPanel();
  1161. JLabel lbl2 = new JLabel("(5 + 5) / 2 = ");
  1162. JTextField txt2 = new JTextField(10);
  1163. panel2.add(lbl2);
  1164. panel2.add(txt2);
  1165. int selectedOption2 = JOptionPane.showOptionDialog(null, panel2, "Question No. 2: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1166. if (selectedOption2 == 0){
  1167. if (Integer.parseInt(txt2.getText()) == 5){
  1168. OScore.setText(String.valueOf(oCount+=1));
  1169. if (Integer.parseInt(OLR.getText()) == 5){
  1170. OLR.setText(String.valueOf(OLife = 5));
  1171. }else {
  1172. OLR.setText(String.valueOf(OLife+=1));
  1173. }
  1174. random++;
  1175. }else {
  1176. OScore.setText(String.valueOf(oCount-=1));
  1177. OLR.setText(String.valueOf(OLife-=1));
  1178. random++;
  1179. }
  1180. }
  1181. break;
  1182. case 3:
  1183. JPanel panel3 = new JPanel();
  1184. JLabel lbl3 = new JLabel("-1 - 1 = ");
  1185. JTextField txt3 = new JTextField(10);
  1186. panel3.add(lbl3);
  1187. panel3.add(txt3);
  1188. int selectedOption3 = JOptionPane.showOptionDialog(null, panel3, "Question No. 3: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1189. if (selectedOption3 == 0){
  1190. if (Integer.parseInt(txt3.getText()) == -2){
  1191. OScore.setText(String.valueOf(oCount+=1));
  1192. if (Integer.parseInt(OLR.getText()) == 5){
  1193. OLR.setText(String.valueOf(OLife = 5));
  1194. }else {
  1195. OLR.setText(String.valueOf(OLife+=1));
  1196. }
  1197. random++;
  1198. }else {
  1199. OScore.setText(String.valueOf(oCount-=1));
  1200. OLR.setText(String.valueOf(OLife-=1));
  1201. random++;
  1202. }
  1203.  
  1204. }
  1205. break;
  1206. case 4:
  1207. JPanel panel4 = new JPanel();
  1208. JLabel lbl4 = new JLabel("10 + (50 * 5) - 6 = ");
  1209. JTextField txt4 = new JTextField(10);
  1210. panel4.add(lbl4);
  1211. panel4.add(txt4);
  1212. int selectedOption4 = JOptionPane.showOptionDialog(null, panel4, "Question No. 4: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1213. if (selectedOption4 == 0){
  1214. if (Integer.parseInt(txt4.getText()) == 254){
  1215. OScore.setText(String.valueOf(oCount+=1));
  1216. if (Integer.parseInt(OLR.getText()) == 5){
  1217. OLR.setText(String.valueOf(OLife = 5));
  1218. }else {
  1219. OLR.setText(String.valueOf(OLife+=1));
  1220. }
  1221. random++;
  1222. }else {
  1223. OScore.setText(String.valueOf(oCount-=1));
  1224. OLR.setText(String.valueOf(OLife-=1));
  1225. random++;
  1226. }
  1227. }
  1228.  
  1229. break;
  1230. case 5:
  1231. JPanel panel5 = new JPanel();
  1232. JLabel lbl5 = new JLabel("100 * 5 + 10 = ");
  1233. JTextField txt5 = new JTextField(10);
  1234. panel5.add(lbl5);
  1235. panel5.add(txt5);
  1236. int selectedOption5 = JOptionPane.showOptionDialog(null, panel5, "Question No. 5: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1237. if (selectedOption5 == 0){
  1238. if (Integer.parseInt(txt5.getText()) == 510){
  1239. OScore.setText(String.valueOf(oCount+=1));
  1240. if (Integer.parseInt(OLR.getText()) == 5){
  1241. OLR.setText(String.valueOf(OLife = 5));
  1242. }else {
  1243. OLR.setText(String.valueOf(OLife+=1));
  1244. }
  1245. random++;
  1246. }else {
  1247. OScore.setText(String.valueOf(oCount-=1));
  1248. OLR.setText(String.valueOf(OLife-=1));
  1249. random++;
  1250. }
  1251. }
  1252. break;
  1253. case 6:
  1254. JPanel panel6 = new JPanel();
  1255. JLabel lbl6 = new JLabel("75 + 55 + 68 = ");
  1256. JTextField txt6 = new JTextField(10);
  1257. panel6.add(lbl6);
  1258. panel6.add(txt6);
  1259. int selectedOption6 = JOptionPane.showOptionDialog(null, panel6, "Question No. 6: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1260. if (selectedOption6 == 0){
  1261. if (Integer.parseInt(txt6.getText()) == 198){
  1262. OScore.setText(String.valueOf(oCount+=1));
  1263. if (Integer.parseInt(OLR.getText()) == 5){
  1264. OLR.setText(String.valueOf(OLife = 5));
  1265. }else {
  1266. OLR.setText(String.valueOf(OLife+=1));
  1267. }
  1268. random++;
  1269. }else {
  1270. OScore.setText(String.valueOf(oCount-=1));
  1271. OLR.setText(String.valueOf(OLife-=1));
  1272. random++;
  1273. }
  1274. }
  1275.  
  1276. break;
  1277. case 7:
  1278. JPanel panel7 = new JPanel();
  1279. JLabel lbl7 = new JLabel("1500 + 700 + (-300) = ");
  1280. JTextField txt7 = new JTextField(10);
  1281. panel7.add(lbl7);
  1282. panel7.add(txt7);
  1283. int selectedOption7 = JOptionPane.showOptionDialog(null, panel7, "Question No. 7: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1284. if (selectedOption7 == 0){
  1285. if (Integer.parseInt(txt7.getText()) == 1900){
  1286. OScore.setText(String.valueOf(oCount+=1));
  1287. if (Integer.parseInt(OLR.getText()) == 5){
  1288. OLR.setText(String.valueOf(OLife = 5));
  1289. }else {
  1290. OLR.setText(String.valueOf(OLife+=1));
  1291. }
  1292. random++;
  1293. }else {
  1294. OScore.setText(String.valueOf(oCount-=1));
  1295. OLR.setText(String.valueOf(OLife-=1));
  1296. random++;
  1297. }
  1298. }
  1299.  
  1300. break;
  1301. case 8:
  1302. JPanel panel8 = new JPanel();
  1303. JLabel lbl8 = new JLabel("900 + 800 + 500 = ");
  1304. JTextField txt8 = new JTextField(10);
  1305. panel8.add(lbl8);
  1306. panel8.add(txt8);
  1307. int selectedOption8 = JOptionPane.showOptionDialog(null, panel8, "Question No. 8: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1308. if (selectedOption8 == 0){
  1309. if (Integer.parseInt(txt8.getText()) == 2200){
  1310. OScore.setText(String.valueOf(oCount+=1));
  1311. if (Integer.parseInt(OLR.getText()) == 5){
  1312. OLR.setText(String.valueOf(OLife = 5));
  1313. }else {
  1314. OLR.setText(String.valueOf(OLife+=1));
  1315. }
  1316. random++;
  1317. }else {
  1318. OScore.setText(String.valueOf(oCount-=1));
  1319. OLR.setText(String.valueOf(OLife-=1));
  1320. random++;
  1321. }
  1322. }
  1323. break;
  1324. case 9:
  1325. JPanel panel9 = new JPanel();
  1326. JLabel lbl9 = new JLabel("-1 - 1 + 1 - 1 + 1 = ");
  1327. JTextField txt9 = new JTextField(10);
  1328. panel9.add(lbl9);
  1329. panel9.add(txt9);
  1330. int selectedOption9 = JOptionPane.showOptionDialog(null, panel9, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1331. if (selectedOption9 == 0){
  1332. if (Integer.parseInt(txt9.getText()) == -1){
  1333. OScore.setText(String.valueOf(oCount+=1));
  1334. if (Integer.parseInt(OLR.getText()) == 5){
  1335. OLR.setText(String.valueOf(OLife = 5));
  1336. }else {
  1337. OLR.setText(String.valueOf(OLife+=1));
  1338. }
  1339. random++;
  1340. }else {
  1341. OScore.setText(String.valueOf(oCount-=1));
  1342. OLR.setText(String.valueOf(OLife-=1));
  1343. random++;
  1344. }
  1345. }
  1346. break;
  1347. case 10:
  1348. JPanel panel10 = new JPanel();
  1349. JLabel lbl10 = new JLabel("800 + 700 =");
  1350. JTextField txt10 = new JTextField(10);
  1351. panel10.add(lbl10);
  1352. panel10.add(txt10);
  1353. int selectedOption10 = JOptionPane.showOptionDialog(null, panel10, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1354. if (selectedOption10 == 0){
  1355. if (Integer.parseInt(txt10.getText()) == 1500){
  1356. OScore.setText(String.valueOf(oCount+=1));
  1357. if (Integer.parseInt(OLR.getText()) == 5){
  1358. OLR.setText(String.valueOf(OLife = 5));
  1359. }else {
  1360. OLR.setText(String.valueOf(OLife+=1));
  1361. }
  1362. random++;
  1363. }else {
  1364. OScore.setText(String.valueOf(oCount-=1));
  1365. OLR.setText(String.valueOf(OLife-=1));
  1366. random++;
  1367. }
  1368. }
  1369. break;
  1370. case 11:
  1371. JPanel panel11 = new JPanel();
  1372. JLabel lbl11 = new JLabel("1900 * 700 / 5 = ");
  1373. JTextField txt11 = new JTextField(10);
  1374. panel11.add(lbl11);
  1375. panel11.add(txt11);
  1376. int selectedOption11 = JOptionPane.showOptionDialog(null, panel11, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1377. if (selectedOption11 == 0){
  1378. if (Integer.parseInt(txt11.getText()) == 266000){
  1379. OScore.setText(String.valueOf(oCount+=1));
  1380. if (Integer.parseInt(OLR.getText()) == 5){
  1381. OLR.setText(String.valueOf(OLife = 5));
  1382. }else {
  1383. OLR.setText(String.valueOf(OLife+=1));
  1384. }
  1385. random++;
  1386. }else {
  1387. OScore.setText(String.valueOf(oCount-=1));
  1388. OLR.setText(String.valueOf(OLife-=1));
  1389. random++;
  1390. }
  1391. }
  1392. break;
  1393. case 12:
  1394. JPanel panel12 = new JPanel();
  1395. JLabel lbl12 = new JLabel("580 + 780 = ");
  1396. JTextField txt12 = new JTextField(10);
  1397. panel12.add(lbl12);
  1398. panel12.add(txt12);
  1399. int selectedOption12 = JOptionPane.showOptionDialog(null, panel12, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1400. if (selectedOption12 == 0){
  1401. if (Integer.parseInt(txt12.getText()) == 1360){
  1402. OScore.setText(String.valueOf(oCount+=1));
  1403. if (Integer.parseInt(OLR.getText()) == 5){
  1404. OLR.setText(String.valueOf(OLife = 5));
  1405. }else {
  1406. OLR.setText(String.valueOf(OLife+=1));
  1407. }
  1408. random++;
  1409. }else {
  1410. OScore.setText(String.valueOf(oCount-=1));
  1411. OLR.setText(String.valueOf(OLife-=1));
  1412. random++;
  1413. }
  1414. }
  1415. break;
  1416. case 13:
  1417. JPanel panel13 = new JPanel();
  1418. JLabel lbl13 = new JLabel("500 - (-9) = ");
  1419. JTextField txt13 = new JTextField(10);
  1420. panel13.add(lbl13);
  1421. panel13.add(txt13);
  1422. int selectedOption13 = JOptionPane.showOptionDialog(null, panel13, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1423. if (selectedOption13 == 0){
  1424. if (Integer.parseInt(txt13.getText()) == 509){
  1425. OScore.setText(String.valueOf(oCount+=1));
  1426. if (Integer.parseInt(OLR.getText()) == 5){
  1427. OLR.setText(String.valueOf(OLife = 5));
  1428. }else {
  1429. OLR.setText(String.valueOf(OLife+=1));
  1430. }
  1431. random++;
  1432. }else {
  1433. OScore.setText(String.valueOf(oCount-=1));
  1434. OLR.setText(String.valueOf(OLife-=1));
  1435. random++;
  1436. }
  1437. }
  1438. break;
  1439.  
  1440. }
  1441. }
  1442.  
  1443. private static void xMediumQuestions(){
  1444. String[] options = {"OK"};
  1445. switch (random){
  1446. case 1:
  1447.  
  1448. JPanel panel = new JPanel();
  1449. JLabel lbl = new JLabel("10 - 2(3) = ");
  1450. JTextField txt = new JTextField(10);
  1451. panel.add(lbl);
  1452. panel.add(txt);
  1453. int selectedOption = JOptionPane.showOptionDialog(null, panel, "Question No. 1: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1454. if(selectedOption == 0)
  1455. {
  1456. if (Integer.parseInt(txt.getText()) == 4){
  1457. XScore.setText(String.valueOf(xCount+=1));
  1458. if (Integer.parseInt(XLR.getText()) == 5){
  1459. XLR.setText(String.valueOf(XLife = 5));
  1460. }else {
  1461. XLR.setText(String.valueOf(XLife+=1));
  1462. }
  1463. random++;
  1464. }else{
  1465. XScore.setText(String.valueOf(xCount-=1));
  1466. XLR.setText(String.valueOf(XLife-=1));
  1467. random++;
  1468. }
  1469. }
  1470. break;
  1471. case 2:
  1472. JPanel panel2 = new JPanel();
  1473. JLabel lbl2 = new JLabel("-2^3 =");
  1474. JTextField txt2 = new JTextField(10);
  1475. panel2.add(lbl2);
  1476. panel2.add(txt2);
  1477. int selectedOption2 = JOptionPane.showOptionDialog(null, panel2, "Question No. 2: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1478. if (selectedOption2 == 0){
  1479. if (Integer.parseInt(txt2.getText()) == -8){
  1480. XScore.setText(String.valueOf(xCount+=1));
  1481. if (Integer.parseInt(XLR.getText()) == 5){
  1482. XLR.setText(String.valueOf(XLife = 5));
  1483. }else {
  1484. XLR.setText(String.valueOf(XLife+=1));
  1485. }
  1486. random++;
  1487. }else {
  1488. XScore.setText(String.valueOf(xCount-=1));
  1489. XLR.setText(String.valueOf(XLife-=1));
  1490. random++;
  1491. }
  1492. }
  1493. break;
  1494. case 3:
  1495. JPanel panel3 = new JPanel();
  1496. JLabel lbl3 = new JLabel("6 - 3^2 = ");
  1497. JTextField txt3 = new JTextField(10);
  1498. panel3.add(lbl3);
  1499. panel3.add(txt3);
  1500. int selectedOption3 = JOptionPane.showOptionDialog(null, panel3, "Question No. 3: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1501. if (selectedOption3 == 0){
  1502. if (Integer.parseInt(txt3.getText()) == -3){
  1503. XScore.setText(String.valueOf(xCount+=1));
  1504. if (Integer.parseInt(XLR.getText()) == 5){
  1505. XLR.setText(String.valueOf(XLife = 5));
  1506. }else {
  1507. XLR.setText(String.valueOf(XLife+=1));
  1508. }
  1509. random++;
  1510. }else {
  1511. XScore.setText(String.valueOf(xCount-=1));
  1512. XLR.setText(String.valueOf(XLife-=1));
  1513. random++;
  1514. }
  1515.  
  1516. }
  1517. break;
  1518. case 4:
  1519. JPanel panel4 = new JPanel();
  1520. JLabel lbl4 = new JLabel("105 ÷ 7 - 25 = ");
  1521. JTextField txt4 = new JTextField(10);
  1522. panel4.add(lbl4);
  1523. panel4.add(txt4);
  1524. int selectedOption4 = JOptionPane.showOptionDialog(null, panel4, "Question No. 4: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1525. if (selectedOption4 == 0){
  1526. if (Integer.parseInt(txt4.getText()) == -10){
  1527. XScore.setText(String.valueOf(xCount+=1));
  1528. if (Integer.parseInt(XLR.getText()) == 5){
  1529. XLR.setText(String.valueOf(XLife = 5));
  1530. }else {
  1531. XLR.setText(String.valueOf(XLife+=1));
  1532. }
  1533. random++;
  1534. }else {
  1535. XScore.setText(String.valueOf(xCount-=1));
  1536. XLR.setText(String.valueOf(XLife-=1));
  1537. random++;
  1538. }
  1539. }
  1540.  
  1541. break;
  1542. case 5:
  1543. JPanel panel5 = new JPanel();
  1544. JLabel lbl5 = new JLabel("496 ÷ 2 + (-20)^2 = ");
  1545. JTextField txt5 = new JTextField(10);
  1546. panel5.add(lbl5);
  1547. panel5.add(txt5);
  1548. int selectedOption5 = JOptionPane.showOptionDialog(null, panel5, "Question No. 5: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1549. if (selectedOption5 == 0){
  1550. if (Integer.parseInt(txt5.getText()) == 648){
  1551. XScore.setText(String.valueOf(xCount+=1));
  1552. if (Integer.parseInt(XLR.getText()) == 5){
  1553. XLR.setText(String.valueOf(XLife = 5));
  1554. }else {
  1555. XLR.setText(String.valueOf(XLife+=1));
  1556. }
  1557. random++;
  1558. }else {
  1559. XScore.setText(String.valueOf(xCount-=1));
  1560. XLR.setText(String.valueOf(XLife-=1));
  1561. random++;
  1562. }
  1563. }
  1564. break;
  1565. case 6:
  1566. JPanel panel6 = new JPanel();
  1567. JLabel lbl6 = new JLabel("1,560 ÷ 5 + 50 - (-2) = ");
  1568. JTextField txt6 = new JTextField(10);
  1569. panel6.add(lbl6);
  1570. panel6.add(txt6);
  1571. int selectedOption6 = JOptionPane.showOptionDialog(null, panel6, "Question No. 6: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1572. if (selectedOption6 == 0){
  1573. if (Integer.parseInt(txt6.getText()) == 1617){
  1574. XScore.setText(String.valueOf(xCount+=1));
  1575. if (Integer.parseInt(XLR.getText()) == 5){
  1576. XLR.setText(String.valueOf(XLife = 5));
  1577. }else {
  1578. XLR.setText(String.valueOf(XLife+=1));
  1579. }
  1580. random++;
  1581. }else {
  1582. XScore.setText(String.valueOf(xCount-=1));
  1583. XLR.setText(String.valueOf(XLife-=1));
  1584. random++;
  1585. }
  1586. }
  1587.  
  1588. break;
  1589. case 7:
  1590. JPanel panel7 = new JPanel();
  1591. JLabel lbl7 = new JLabel("765 ÷ 9^2 + 20 = ");
  1592. JTextField txt7 = new JTextField(10);
  1593. panel7.add(lbl7);
  1594. panel7.add(txt7);
  1595. int selectedOption7 = JOptionPane.showOptionDialog(null, panel7, "Question No. 7: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1596. if (selectedOption7 == 0){
  1597. if (Integer.parseInt(txt7.getText()) == 866){
  1598. XScore.setText(String.valueOf(xCount+=1));
  1599. if (Integer.parseInt(XLR.getText()) == 5){
  1600. XLR.setText(String.valueOf(XLife = 5));
  1601. }else {
  1602. XLR.setText(String.valueOf(XLife+=1));
  1603. }
  1604. random++;
  1605. }else {
  1606. XScore.setText(String.valueOf(xCount-=1));
  1607. XLR.setText(String.valueOf(XLife-=1));
  1608. random++;
  1609. }
  1610. }
  1611.  
  1612. break;
  1613. case 8:
  1614. JPanel panel8 = new JPanel();
  1615. JLabel lbl8 = new JLabel("1000 + 10000 - 10^4 = ");
  1616. JTextField txt8 = new JTextField(10);
  1617. panel8.add(lbl8);
  1618. panel8.add(txt8);
  1619. int selectedOption8 = JOptionPane.showOptionDialog(null, panel8, "Question No. 8: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1620. if (selectedOption8 == 0){
  1621. if (Integer.parseInt(txt8.getText()) == 10){
  1622. XScore.setText(String.valueOf(xCount+=1));
  1623. if (Integer.parseInt(XLR.getText()) == 5){
  1624. XLR.setText(String.valueOf(XLife = 5));
  1625. }else {
  1626. XLR.setText(String.valueOf(XLife+=1));
  1627. }
  1628. random++;
  1629. }else {
  1630. XScore.setText(String.valueOf(xCount-=1));
  1631. XLR.setText(String.valueOf(XLife-=1));
  1632. random++;
  1633. }
  1634. }
  1635. break;
  1636. case 9:
  1637. JPanel panel9 = new JPanel();
  1638. JLabel lbl9 = new JLabel("2,550 ÷ 25 + 50 = ");
  1639. JTextField txt9 = new JTextField(10);
  1640. panel9.add(lbl9);
  1641. panel9.add(txt9);
  1642. int selectedOption9 = JOptionPane.showOptionDialog(null, panel9, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1643. if (selectedOption9 == 0){
  1644. if (Integer.parseInt(txt9.getText()) == 152){
  1645. XScore.setText(String.valueOf(xCount+=1));
  1646. if (Integer.parseInt(XLR.getText()) == 5){
  1647. XLR.setText(String.valueOf(XLife = 5));
  1648. }else {
  1649. XLR.setText(String.valueOf(XLife+=1));
  1650. }
  1651. random++;
  1652. }else {
  1653. XScore.setText(String.valueOf(xCount-=1));
  1654. XLR.setText(String.valueOf(XLife-=1));
  1655. random++;
  1656. }
  1657. }
  1658. break;
  1659. case 10:
  1660. JPanel panel10 = new JPanel();
  1661. JLabel lbl10 = new JLabel("456 + 958 + (-1000) =");
  1662. JTextField txt10 = new JTextField(10);
  1663. panel10.add(lbl10);
  1664. panel10.add(txt10);
  1665. int selectedOption10 = JOptionPane.showOptionDialog(null, panel10, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1666. if (selectedOption10 == 0){
  1667. if (Integer.parseInt(txt10.getText()) == 414){
  1668. XScore.setText(String.valueOf(xCount+=1));
  1669. if (Integer.parseInt(XLR.getText()) == 5){
  1670. XLR.setText(String.valueOf(XLife = 5));
  1671. }else {
  1672. XLR.setText(String.valueOf(XLife+=1));
  1673. }
  1674. random++;
  1675. }else {
  1676. XScore.setText(String.valueOf(xCount-=1));
  1677. XLR.setText(String.valueOf(XLife-=1));
  1678. random++;
  1679. }
  1680. }
  1681. break;
  1682. case 11:
  1683. JPanel panel11 = new JPanel();
  1684. JLabel lbl11 = new JLabel("73 + 67 + 5800 + 7500 = ");
  1685. JTextField txt11 = new JTextField(10);
  1686. panel11.add(lbl11);
  1687. panel11.add(txt11);
  1688. int selectedOption11 = JOptionPane.showOptionDialog(null, panel11, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1689. if (selectedOption11 == 0){
  1690. if (Integer.parseInt(txt11.getText()) == 13440){
  1691. XScore.setText(String.valueOf(xCount+=1));
  1692. if (Integer.parseInt(XLR.getText()) == 5){
  1693. XLR.setText(String.valueOf(XLife = 5));
  1694. }else {
  1695. XLR.setText(String.valueOf(XLife+=1));
  1696. }
  1697. random++;
  1698. }else {
  1699. XScore.setText(String.valueOf(xCount-=1));
  1700. XLR.setText(String.valueOf(XLife-=1));
  1701. random++;
  1702. }
  1703. }
  1704. break;
  1705. case 12:
  1706. JPanel panel12 = new JPanel();
  1707. JLabel lbl12 = new JLabel("88 + 89 * 50 = ");
  1708. JTextField txt12 = new JTextField(10);
  1709. panel12.add(lbl12);
  1710. panel12.add(txt12);
  1711. int selectedOption12 = JOptionPane.showOptionDialog(null, panel12, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1712. if (selectedOption12 == 0){
  1713. if (Integer.parseInt(txt12.getText()) == 4538){
  1714. XScore.setText(String.valueOf(xCount+=1));
  1715. if (Integer.parseInt(XLR.getText()) == 5){
  1716. XLR.setText(String.valueOf(XLife = 5));
  1717. }else {
  1718. XLR.setText(String.valueOf(XLife+=1));
  1719. }
  1720. random++;
  1721. }else {
  1722. XScore.setText(String.valueOf(xCount-=1));
  1723. XLR.setText(String.valueOf(XLife-=1));
  1724. random++;
  1725. }
  1726. }
  1727. break;
  1728. case 13:
  1729. JPanel panel13 = new JPanel();
  1730. JLabel lbl13 = new JLabel("1800 + 1200 + 75 = ");
  1731. JTextField txt13 = new JTextField(10);
  1732. panel13.add(lbl13);
  1733. panel13.add(txt13);
  1734. int selectedOption13 = JOptionPane.showOptionDialog(null, panel13, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1735. if (selectedOption13 == 0){
  1736. if (Integer.parseInt(txt13.getText()) == 3075){
  1737. XScore.setText(String.valueOf(xCount+=1));
  1738. if (Integer.parseInt(XLR.getText()) == 5){
  1739. XLR.setText(String.valueOf(XLife = 5));
  1740. }else {
  1741. XLR.setText(String.valueOf(XLife+=1));
  1742. }
  1743. random++;
  1744. }else {
  1745. XScore.setText(String.valueOf(xCount-=1));
  1746. XLR.setText(String.valueOf(XLife-=1));
  1747. random++;
  1748. }
  1749. }
  1750. break;
  1751.  
  1752. }
  1753. }
  1754.  
  1755. private static void oMediumQuestions(){
  1756. String[] options = {"OK"};
  1757. switch (random){
  1758. case 1:
  1759.  
  1760. JPanel panel = new JPanel();
  1761. JLabel lbl = new JLabel("10 - 2(3) = ");
  1762. JTextField txt = new JTextField(10);
  1763. panel.add(lbl);
  1764. panel.add(txt);
  1765. int selectedOption = JOptionPane.showOptionDialog(null, panel, "Question No. 1: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1766.  
  1767. if(selectedOption == 0)
  1768. {
  1769. if (Integer.parseInt(txt.getText()) == 4){
  1770. OScore.setText(String.valueOf(oCount+=1));
  1771. if (Integer.parseInt(OLR.getText()) == 5){
  1772. OLR.setText(String.valueOf(OLife = 5));
  1773. }else {
  1774. OLR.setText(String.valueOf(OLife+=1));
  1775. }
  1776. random++;
  1777. }else{
  1778. OScore.setText(String.valueOf(oCount-=1));
  1779. OLR.setText(String.valueOf(OLife-=1));
  1780. random++;
  1781. }
  1782. }
  1783. break;
  1784. case 2:
  1785. JPanel panel2 = new JPanel();
  1786. JLabel lbl2 = new JLabel("-2^3 =");
  1787. JTextField txt2 = new JTextField(10);
  1788. panel2.add(lbl2);
  1789. panel2.add(txt2);
  1790. int selectedOption2 = JOptionPane.showOptionDialog(null, panel2, "Question No. 2: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1791. if (selectedOption2 == 0){
  1792. if (Integer.parseInt(txt2.getText()) == -8){
  1793. OScore.setText(String.valueOf(oCount+=1));
  1794. if (Integer.parseInt(OLR.getText()) == 5){
  1795. OLR.setText(String.valueOf(OLife = 5));
  1796. }else {
  1797. OLR.setText(String.valueOf(OLife+=1));
  1798. }
  1799. random++;
  1800. }else {
  1801. OScore.setText(String.valueOf(oCount-=1));
  1802. OLR.setText(String.valueOf(OLife-=1));
  1803. random++;
  1804. }
  1805. }
  1806. break;
  1807. case 3:
  1808. JPanel panel3 = new JPanel();
  1809. JLabel lbl3 = new JLabel("6 - 3^2 = ");
  1810. JTextField txt3 = new JTextField(10);
  1811. panel3.add(lbl3);
  1812. panel3.add(txt3);
  1813. int selectedOption3 = JOptionPane.showOptionDialog(null, panel3, "Question No. 3: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1814. if (selectedOption3 == 0){
  1815. if (Integer.parseInt(txt3.getText()) == -3){
  1816. OScore.setText(String.valueOf(oCount+=1));
  1817. if (Integer.parseInt(OLR.getText()) == 5){
  1818. OLR.setText(String.valueOf(OLife = 5));
  1819. }else {
  1820. OLR.setText(String.valueOf(OLife+=1));
  1821. }
  1822. random++;
  1823. }else {
  1824. OScore.setText(String.valueOf(oCount-=1));
  1825. OLR.setText(String.valueOf(OLife-=1));
  1826. random++;
  1827. }
  1828.  
  1829. }
  1830. break;
  1831. case 4:
  1832. JPanel panel4 = new JPanel();
  1833. JLabel lbl4 = new JLabel("105 / 7 - 25 = ");
  1834. JTextField txt4 = new JTextField(10);
  1835. panel4.add(lbl4);
  1836. panel4.add(txt4);
  1837. int selectedOption4 = JOptionPane.showOptionDialog(null, panel4, "Question No. 4: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1838. if (selectedOption4 == 0){
  1839. if (Integer.parseInt(txt4.getText()) == -10){
  1840. OScore.setText(String.valueOf(oCount+=1));
  1841. if (Integer.parseInt(OLR.getText()) == 5){
  1842. OLR.setText(String.valueOf(OLife = 5));
  1843. }else {
  1844. OLR.setText(String.valueOf(OLife+=1));
  1845. }
  1846. random++;
  1847. }else {
  1848. OScore.setText(String.valueOf(oCount-=1));
  1849. OLR.setText(String.valueOf(OLife-=1));
  1850. random++;
  1851. }
  1852. }
  1853.  
  1854. break;
  1855. case 5:
  1856. JPanel panel5 = new JPanel();
  1857. JLabel lbl5 = new JLabel("496 / 2 + (-20)^2 = ");
  1858. JTextField txt5 = new JTextField(10);
  1859. panel5.add(lbl5);
  1860. panel5.add(txt5);
  1861. int selectedOption5 = JOptionPane.showOptionDialog(null, panel5, "Question No. 5: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1862. if (selectedOption5 == 0){
  1863. if (Integer.parseInt(txt5.getText()) == 648){
  1864. OScore.setText(String.valueOf(oCount+=1));
  1865. if (Integer.parseInt(OLR.getText()) == 5){
  1866. OLR.setText(String.valueOf(OLife = 5));
  1867. }else {
  1868. OLR.setText(String.valueOf(OLife+=1));
  1869. }
  1870. random++;
  1871. }else {
  1872. OScore.setText(String.valueOf(oCount-=1));
  1873. OLR.setText(String.valueOf(OLife-=1));
  1874. random++;
  1875. }
  1876. }
  1877. break;
  1878. case 6:
  1879. JPanel panel6 = new JPanel();
  1880. JLabel lbl6 = new JLabel("1560 / 5 + 50 - (-2) = ");
  1881. JTextField txt6 = new JTextField(10);
  1882. panel6.add(lbl6);
  1883. panel6.add(txt6);
  1884. int selectedOption6 = JOptionPane.showOptionDialog(null, panel6, "Question No. 6: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1885. if (selectedOption6 == 0){
  1886. if (Integer.parseInt(txt6.getText()) == 1617){
  1887. OScore.setText(String.valueOf(oCount+=1));
  1888. if (Integer.parseInt(OLR.getText()) == 5){
  1889. OLR.setText(String.valueOf(OLife = 5));
  1890. }else {
  1891. OLR.setText(String.valueOf(OLife+=1));
  1892. }
  1893. random++;
  1894. }else {
  1895. OScore.setText(String.valueOf(oCount-=1));
  1896. OLR.setText(String.valueOf(OLife-=1));
  1897. random++;
  1898. }
  1899. }
  1900.  
  1901. break;
  1902. case 7:
  1903. JPanel panel7 = new JPanel();
  1904. JLabel lbl7 = new JLabel("765 / 9^2 + 20 = ");
  1905. JTextField txt7 = new JTextField(10);
  1906. panel7.add(lbl7);
  1907. panel7.add(txt7);
  1908. int selectedOption7 = JOptionPane.showOptionDialog(null, panel7, "Question No. 7: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1909. if (selectedOption7 == 0){
  1910. if (Integer.parseInt(txt7.getText()) == 866){
  1911. OScore.setText(String.valueOf(oCount+=1));
  1912. if (Integer.parseInt(OLR.getText()) == 5){
  1913. OLR.setText(String.valueOf(OLife = 5));
  1914. }else {
  1915. OLR.setText(String.valueOf(OLife+=1));
  1916. }
  1917. random++;
  1918. }else {
  1919. OScore.setText(String.valueOf(oCount-=1));
  1920. OLR.setText(String.valueOf(OLife-=1));
  1921. random++;
  1922. }
  1923. }
  1924.  
  1925. break;
  1926. case 8:
  1927. JPanel panel8 = new JPanel();
  1928. JLabel lbl8 = new JLabel("1000 + 10000 - 10^4 = ");
  1929. JTextField txt8 = new JTextField(10);
  1930. panel8.add(lbl8);
  1931. panel8.add(txt8);
  1932. int selectedOption8 = JOptionPane.showOptionDialog(null, panel8, "Question No. 8: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1933. if (selectedOption8 == 0){
  1934. if (Integer.parseInt(txt8.getText()) == 10){
  1935. OScore.setText(String.valueOf(oCount+=1));
  1936. if (Integer.parseInt(OLR.getText()) == 5){
  1937. OLR.setText(String.valueOf(OLife = 5));
  1938. }else {
  1939. OLR.setText(String.valueOf(OLife+=1));
  1940. }
  1941. random++;
  1942. }else {
  1943. OScore.setText(String.valueOf(oCount-=1));
  1944. OLR.setText(String.valueOf(OLife-=1));
  1945. random++;
  1946. }
  1947. }
  1948. break;
  1949. case 9:
  1950. JPanel panel9 = new JPanel();
  1951. JLabel lbl9 = new JLabel("2550 / 25 + 50 = ");
  1952. JTextField txt9 = new JTextField(10);
  1953. panel9.add(lbl9);
  1954. panel9.add(txt9);
  1955. int selectedOption9 = JOptionPane.showOptionDialog(null, panel9, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1956. if (selectedOption9 == 0){
  1957. if (Integer.parseInt(txt9.getText()) == 152){
  1958. OScore.setText(String.valueOf(oCount+=1));
  1959. if (Integer.parseInt(OLR.getText()) == 5){
  1960. OLR.setText(String.valueOf(OLife = 5));
  1961. }else {
  1962. OLR.setText(String.valueOf(OLife+=1));
  1963. }
  1964. random++;
  1965. }else {
  1966. OScore.setText(String.valueOf(oCount-=1));
  1967. OLR.setText(String.valueOf(OLife-=1));
  1968. random++;
  1969. }
  1970. }
  1971. break;
  1972. case 10:
  1973. JPanel panel10 = new JPanel();
  1974. JLabel lbl10 = new JLabel("456 + 958 + (-1000) =");
  1975. JTextField txt10 = new JTextField(10);
  1976. panel10.add(lbl10);
  1977. panel10.add(txt10);
  1978. int selectedOption10 = JOptionPane.showOptionDialog(null, panel10, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  1979. if (selectedOption10 == 0){
  1980. if (Integer.parseInt(txt10.getText()) == 414){
  1981. OScore.setText(String.valueOf(oCount+=1));
  1982. if (Integer.parseInt(OLR.getText()) == 5){
  1983. OLR.setText(String.valueOf(OLife = 5));
  1984. }else {
  1985. OLR.setText(String.valueOf(OLife+=1));
  1986. }
  1987. random++;
  1988. }else {
  1989. OScore.setText(String.valueOf(oCount-=1));
  1990. OLR.setText(String.valueOf(OLife-=1));
  1991. random++;
  1992. }
  1993. }
  1994. break;
  1995. case 11:
  1996. JPanel panel11 = new JPanel();
  1997. JLabel lbl11 = new JLabel("73 + 67 + 5800 + 7500 = ");
  1998. JTextField txt11 = new JTextField(10);
  1999. panel11.add(lbl11);
  2000. panel11.add(txt11);
  2001. int selectedOption11 = JOptionPane.showOptionDialog(null, panel11, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2002. if (selectedOption11 == 0){
  2003. if (Integer.parseInt(txt11.getText()) == 13440){
  2004. OScore.setText(String.valueOf(oCount+=1));
  2005. if (Integer.parseInt(OLR.getText()) == 5){
  2006. OLR.setText(String.valueOf(OLife = 5));
  2007. }else {
  2008. OLR.setText(String.valueOf(OLife+=1));
  2009. }
  2010. random++;
  2011. }else {
  2012. OScore.setText(String.valueOf(oCount-=1));
  2013. OLR.setText(String.valueOf(OLife-=1));
  2014. random++;
  2015. }
  2016. }
  2017. break;
  2018. case 12:
  2019. JPanel panel12 = new JPanel();
  2020. JLabel lbl12 = new JLabel("88 + 89 * 50 = ");
  2021. JTextField txt12 = new JTextField(10);
  2022. panel12.add(lbl12);
  2023. panel12.add(txt12);
  2024. int selectedOption12 = JOptionPane.showOptionDialog(null, panel12, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2025. if (selectedOption12 == 0){
  2026. if (Integer.parseInt(txt12.getText()) == 4538){
  2027. OScore.setText(String.valueOf(oCount+=1));
  2028. if (Integer.parseInt(OLR.getText()) == 5){
  2029. OLR.setText(String.valueOf(OLife = 5));
  2030. }else {
  2031. OLR.setText(String.valueOf(OLife+=1));
  2032. }
  2033. random++;
  2034. }else {
  2035. OScore.setText(String.valueOf(oCount-=1));
  2036. OLR.setText(String.valueOf(OLife-=1));
  2037. random++;
  2038. }
  2039. }
  2040. break;
  2041. case 13:
  2042. JPanel panel13 = new JPanel();
  2043. JLabel lbl13 = new JLabel("1800 + 1200 + 75 = ");
  2044. JTextField txt13 = new JTextField(10);
  2045. panel13.add(lbl13);
  2046. panel13.add(txt13);
  2047. int selectedOption13 = JOptionPane.showOptionDialog(null, panel13, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2048. if (selectedOption13 == 0){
  2049. if (Integer.parseInt(txt13.getText()) == 3075){
  2050. OScore.setText(String.valueOf(oCount+=1));
  2051. if (Integer.parseInt(OLR.getText()) == 5){
  2052. OLR.setText(String.valueOf(OLife = 5));
  2053. }else {
  2054. OLR.setText(String.valueOf(OLife+=1));
  2055. }
  2056. random++;
  2057. }else {
  2058. OScore.setText(String.valueOf(oCount-=1));
  2059. OLR.setText(String.valueOf(OLife-=1));
  2060. random++;
  2061. }
  2062. }
  2063. break;
  2064.  
  2065. }
  2066. }
  2067.  
  2068. private static void xHardQuestions(){
  2069. String[] options = {"OK"};
  2070. switch (random){
  2071. case 1:
  2072.  
  2073. JPanel panel = new JPanel();
  2074. JLabel lbl = new JLabel("5 + (-24) + 3 square root(64) = ");
  2075. JTextField txt = new JTextField(10);
  2076. panel.add(lbl);
  2077. panel.add(txt);
  2078. int selectedOption = JOptionPane.showOptionDialog(null, panel, "Question No. 1: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2079. if(selectedOption == 0)
  2080. {
  2081. if (Integer.parseInt(txt.getText()) == 5){
  2082. XScore.setText(String.valueOf(xCount+=1));
  2083. if (Integer.parseInt(XLR.getText()) == 5){
  2084. XLR.setText(String.valueOf(XLife = 5));
  2085. }else {
  2086. XLR.setText(String.valueOf(XLife+=1));
  2087. }
  2088. random++;
  2089. }else{
  2090. XScore.setText(String.valueOf(xCount-=1));
  2091. XLR.setText(String.valueOf(XLife-=1));
  2092. random++;
  2093. }
  2094. }
  2095. break;
  2096. case 2:
  2097. JPanel panel2 = new JPanel();
  2098. JLabel lbl2 = new JLabel("52 / 5 + 89 - 3 square root(6)^2 = ");
  2099. JTextField txt2 = new JTextField(10);
  2100. panel2.add(lbl2);
  2101. panel2.add(txt2);
  2102. int selectedOption2 = JOptionPane.showOptionDialog(null, panel2, "Question No. 2: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2103. if (selectedOption2 == 0){
  2104. if (Double.parseDouble(txt2.getText()) == 81.40){
  2105. XScore.setText(String.valueOf(xCount+=1));
  2106. if (Integer.parseInt(XLR.getText()) == 5){
  2107. XLR.setText(String.valueOf(XLife = 5));
  2108. }else {
  2109. XLR.setText(String.valueOf(XLife+=1));
  2110. }
  2111. random++;
  2112. }else {
  2113. XScore.setText(String.valueOf(xCount-=1));
  2114. XLR.setText(String.valueOf(XLife-=1));
  2115. random++;
  2116. }
  2117. }
  2118. break;
  2119. case 3:
  2120. JPanel panel3 = new JPanel();
  2121. JLabel lbl3 = new JLabel("4^5 * 6 + 89 + square root(6)^5 = ");
  2122. JTextField txt3 = new JTextField(10);
  2123. panel3.add(lbl3);
  2124. panel3.add(txt3);
  2125. int selectedOption3 = JOptionPane.showOptionDialog(null, panel3, "Question No. 3: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2126. if (selectedOption3 == 0){
  2127. if (Double.parseDouble(txt3.getText()) == 157.21){
  2128. XScore.setText(String.valueOf(xCount+=1));
  2129. if (Integer.parseInt(XLR.getText()) == 5){
  2130. XLR.setText(String.valueOf(XLife = 5));
  2131. }else {
  2132. XLR.setText(String.valueOf(XLife+=1));
  2133. }
  2134. random++;
  2135. }else {
  2136. XScore.setText(String.valueOf(xCount-=1));
  2137. XLR.setText(String.valueOf(XLife-=1));
  2138. random++;
  2139. }
  2140.  
  2141. }
  2142. break;
  2143. case 4:
  2144. JPanel panel4 = new JPanel();
  2145. JLabel lbl4 = new JLabel("75(89^2 + 56^2) = ");
  2146. JTextField txt4 = new JTextField(10);
  2147. panel4.add(lbl4);
  2148. panel4.add(txt4);
  2149. int selectedOption4 = JOptionPane.showOptionDialog(null, panel4, "Question No. 4: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2150. if (selectedOption4 == 0){
  2151. if (Double.parseDouble(txt4.getText()) == 829275){
  2152. XScore.setText(String.valueOf(xCount+=1));
  2153. if (Integer.parseInt(XLR.getText()) == 5){
  2154. XLR.setText(String.valueOf(XLife = 5));
  2155. }else {
  2156. XLR.setText(String.valueOf(XLife+=1));
  2157. }
  2158. random++;
  2159. }else {
  2160. XScore.setText(String.valueOf(xCount-=1));
  2161. XLR.setText(String.valueOf(XLife-=1));
  2162. random++;
  2163. }
  2164. }
  2165.  
  2166. break;
  2167. case 5:
  2168. JPanel panel5 = new JPanel();
  2169. JLabel lbl5 = new JLabel("3^4 / 68 / 59 = ");
  2170. JTextField txt5 = new JTextField(10);
  2171. panel5.add(lbl5);
  2172. panel5.add(txt5);
  2173. int selectedOption5 = JOptionPane.showOptionDialog(null, panel5, "Question No. 5: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2174. if (selectedOption5 == 0){
  2175. if (Double.parseDouble(txt5.getText()) == 0.02){
  2176. XScore.setText(String.valueOf(xCount+=1));
  2177. if (Integer.parseInt(XLR.getText()) == 5){
  2178. XLR.setText(String.valueOf(XLife = 5));
  2179. }else {
  2180. XLR.setText(String.valueOf(XLife+=1));
  2181. }
  2182. random++;
  2183. }else {
  2184. XScore.setText(String.valueOf(xCount-=1));
  2185. XLR.setText(String.valueOf(XLife-=1));
  2186. random++;
  2187. }
  2188. }
  2189. break;
  2190. case 6:
  2191. JPanel panel6 = new JPanel();
  2192. JLabel lbl6 = new JLabel("cos(56) + 64 = ");
  2193. JTextField txt6 = new JTextField(10);
  2194. panel6.add(lbl6);
  2195. panel6.add(txt6);
  2196. int selectedOption6 = JOptionPane.showOptionDialog(null, panel6, "Question No. 6: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2197. if (selectedOption6 == 0){
  2198. if (Double.parseDouble(txt6.getText()) == 64.55){
  2199. XScore.setText(String.valueOf(xCount+=1));
  2200. if (Integer.parseInt(XLR.getText()) == 5){
  2201. XLR.setText(String.valueOf(XLife = 5));
  2202. }else {
  2203. XLR.setText(String.valueOf(XLife+=1));
  2204. }
  2205. random++;
  2206. }else {
  2207. XScore.setText(String.valueOf(xCount-=1));
  2208. XLR.setText(String.valueOf(XLife-=1));
  2209. random++;
  2210. }
  2211. }
  2212.  
  2213. break;
  2214. case 7:
  2215. JPanel panel7 = new JPanel();
  2216. JLabel lbl7 = new JLabel("sin(89)^2 = ");
  2217. JTextField txt7 = new JTextField(10);
  2218. panel7.add(lbl7);
  2219. panel7.add(txt7);
  2220. int selectedOption7 = JOptionPane.showOptionDialog(null, panel7, "Question No. 7: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2221. if (selectedOption7 == 0){
  2222. if (Double.parseDouble(txt7.getText()) == 0.99){
  2223. XScore.setText(String.valueOf(xCount+=1));
  2224. if (Integer.parseInt(XLR.getText()) == 5){
  2225. XLR.setText(String.valueOf(XLife = 5));
  2226. }else {
  2227. XLR.setText(String.valueOf(XLife+=1));
  2228. }
  2229. random++;
  2230. }else {
  2231. XScore.setText(String.valueOf(xCount-=1));
  2232. XLR.setText(String.valueOf(XLife-=1));
  2233. random++;
  2234. }
  2235. }
  2236.  
  2237. break;
  2238. case 8:
  2239. JPanel panel8 = new JPanel();
  2240. JLabel lbl8 = new JLabel("tan(89) + sin(89) = ");
  2241. JTextField txt8 = new JTextField(10);
  2242. panel8.add(lbl8);
  2243. panel8.add(txt8);
  2244. int selectedOption8 = JOptionPane.showOptionDialog(null, panel8, "Question No. 8: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2245. if (selectedOption8 == 0){
  2246. if (Double.parseDouble(txt8.getText()) == 58.28){
  2247. XScore.setText(String.valueOf(xCount+=1));
  2248. if (Integer.parseInt(XLR.getText()) == 5){
  2249. XLR.setText(String.valueOf(XLife = 5));
  2250. }else {
  2251. XLR.setText(String.valueOf(XLife+=1));
  2252. }
  2253. random++;
  2254. }else {
  2255. XScore.setText(String.valueOf(xCount-=1));
  2256. XLR.setText(String.valueOf(XLife-=1));
  2257. random++;
  2258. }
  2259. }
  2260. break;
  2261. case 9:
  2262. JPanel panel9 = new JPanel();
  2263. JLabel lbl9 = new JLabel("8 square root(68)^2 + 5 = ");
  2264. JTextField txt9 = new JTextField(10);
  2265. panel9.add(lbl9);
  2266. panel9.add(txt9);
  2267. int selectedOption9 = JOptionPane.showOptionDialog(null, panel9, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2268. if (selectedOption9 == 0){
  2269. if (Double.parseDouble(txt9.getText()) == 243.28){
  2270. XScore.setText(String.valueOf(xCount+=1));
  2271. if (Integer.parseInt(XLR.getText()) == 5){
  2272. XLR.setText(String.valueOf(XLife = 5));
  2273. }else {
  2274. XLR.setText(String.valueOf(XLife+=1));
  2275. }
  2276. random++;
  2277. }else {
  2278. XScore.setText(String.valueOf(xCount-=1));
  2279. XLR.setText(String.valueOf(XLife-=1));
  2280. random++;
  2281. }
  2282. }
  2283. break;
  2284. case 10:
  2285. JPanel panel10 = new JPanel();
  2286. JLabel lbl10 = new JLabel("sin(89) + 6 square root(5)^2 = ");
  2287. JTextField txt10 = new JTextField(10);
  2288. panel10.add(lbl10);
  2289. panel10.add(txt10);
  2290. int selectedOption10 = JOptionPane.showOptionDialog(null, panel10, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2291. if (selectedOption10 == 0){
  2292. if (Double.parseDouble(txt10.getText()) == 30.99){
  2293. XScore.setText(String.valueOf(xCount+=1));
  2294. if (Integer.parseInt(XLR.getText()) == 5){
  2295. XLR.setText(String.valueOf(XLife = 5));
  2296. }else {
  2297. XLR.setText(String.valueOf(XLife+=1));
  2298. }
  2299. random++;
  2300. }else {
  2301. XScore.setText(String.valueOf(xCount-=1));
  2302. XLR.setText(String.valueOf(XLife-=1));
  2303. random++;
  2304. }
  2305. }
  2306. break;
  2307. case 11:
  2308. JPanel panel11 = new JPanel();
  2309. JLabel lbl11 = new JLabel("56^2 + 56^2 / 69 = ");
  2310. JTextField txt11 = new JTextField(10);
  2311. panel11.add(lbl11);
  2312. panel11.add(txt11);
  2313. int selectedOption11 = JOptionPane.showOptionDialog(null, panel11, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2314. if (selectedOption11 == 0){
  2315. if (Double.parseDouble(txt11.getText()) == 3181.44){
  2316. XScore.setText(String.valueOf(xCount+=1));
  2317. if (Integer.parseInt(XLR.getText()) == 5){
  2318. XLR.setText(String.valueOf(XLife = 5));
  2319. }else {
  2320. XLR.setText(String.valueOf(XLife+=1));
  2321. }
  2322. random++;
  2323. }else {
  2324. XScore.setText(String.valueOf(xCount-=1));
  2325. XLR.setText(String.valueOf(XLife-=1));
  2326. random++;
  2327. }
  2328. }
  2329. break;
  2330. case 12:
  2331. JPanel panel12 = new JPanel();
  2332. JLabel lbl12 = new JLabel("89 + tan(65) = ");
  2333. JTextField txt12 = new JTextField(10);
  2334. panel12.add(lbl12);
  2335. panel12.add(txt12);
  2336. int selectedOption12 = JOptionPane.showOptionDialog(null, panel12, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2337. if (selectedOption12 == 0){
  2338. if (Double.parseDouble(txt12.getText()) == 91.14){
  2339. XScore.setText(String.valueOf(xCount+=1));
  2340. if (Integer.parseInt(XLR.getText()) == 5){
  2341. XLR.setText(String.valueOf(XLife = 5));
  2342. }else {
  2343. XLR.setText(String.valueOf(XLife+=1));
  2344. }
  2345. random++;
  2346. }else {
  2347. XScore.setText(String.valueOf(xCount-=1));
  2348. XLR.setText(String.valueOf(XLife-=1));
  2349. random++;
  2350. }
  2351. }
  2352. break;
  2353. case 13:
  2354. JPanel panel13 = new JPanel();
  2355. JLabel lbl13 = new JLabel("56 + 79^2 + 69^3 = ");
  2356. JTextField txt13 = new JTextField(10);
  2357. panel13.add(lbl13);
  2358. panel13.add(txt13);
  2359. int selectedOption13 = JOptionPane.showOptionDialog(null, panel13, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2360. if (selectedOption13 == 0){
  2361. if (Integer.parseInt(txt13.getText()) == 334806){
  2362. XScore.setText(String.valueOf(xCount+=1));
  2363. if (Integer.parseInt(XLR.getText()) == 5){
  2364. XLR.setText(String.valueOf(XLife = 5));
  2365. }else {
  2366. XLR.setText(String.valueOf(XLife+=1));
  2367. }
  2368. random++;
  2369. }else {
  2370. XScore.setText(String.valueOf(xCount-=1));
  2371. XLR.setText(String.valueOf(XLife-=1));
  2372. random++;
  2373. }
  2374. }
  2375. break;
  2376.  
  2377. }
  2378. }
  2379.  
  2380. private static void oHardQuestions(){
  2381. String[] options = {"OK"};
  2382. switch (random){
  2383. case 1:
  2384.  
  2385. JPanel panel = new JPanel();
  2386. JLabel lbl = new JLabel("5 + (-24) + 3 square root(64) = ");
  2387. JTextField txt = new JTextField(10);
  2388. panel.add(lbl);
  2389. panel.add(txt);
  2390. int selectedOption = JOptionPane.showOptionDialog(null, panel, "Question No. 1: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2391.  
  2392. if(selectedOption == 0)
  2393. {
  2394. if (Integer.parseInt(txt.getText()) == 5){
  2395. OScore.setText(String.valueOf(oCount+=1));
  2396. if (Integer.parseInt(OLR.getText()) == 5){
  2397. OLR.setText(String.valueOf(OLife = 5));
  2398. }else {
  2399. OLR.setText(String.valueOf(OLife+=1));
  2400. }
  2401. random++;
  2402. }else{
  2403. OScore.setText(String.valueOf(oCount-=1));
  2404. OLR.setText(String.valueOf(OLife-=1));
  2405. random++;
  2406. }
  2407. }
  2408. break;
  2409. case 2:
  2410. JPanel panel2 = new JPanel();
  2411. JLabel lbl2 = new JLabel("52 / 5 + 89 - 3 square root(6)^2 = ");
  2412. JTextField txt2 = new JTextField(10);
  2413. panel2.add(lbl2);
  2414. panel2.add(txt2);
  2415. int selectedOption2 = JOptionPane.showOptionDialog(null, panel2, "Question No. 2: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2416. if (selectedOption2 == 0){
  2417. if (Double.parseDouble(txt2.getText()) == 81.40){
  2418. OScore.setText(String.valueOf(oCount+=1));
  2419. if (Integer.parseInt(OLR.getText()) == 5){
  2420. OLR.setText(String.valueOf(OLife = 5));
  2421. }else {
  2422. OLR.setText(String.valueOf(OLife+=1));
  2423. }
  2424. random++;
  2425. }else {
  2426. OScore.setText(String.valueOf(oCount-=1));
  2427. OLR.setText(String.valueOf(OLife-=1));
  2428. random++;
  2429. }
  2430. }
  2431. break;
  2432. case 3:
  2433. JPanel panel3 = new JPanel();
  2434. JLabel lbl3 = new JLabel("4^5 * 6 + 89 + square root(6)^5 = ");
  2435. JTextField txt3 = new JTextField(10);
  2436. panel3.add(lbl3);
  2437. panel3.add(txt3);
  2438. int selectedOption3 = JOptionPane.showOptionDialog(null, panel3, "Question No. 3: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2439. if (selectedOption3 == 0){
  2440. if (Double.parseDouble(txt3.getText()) == 157.21){
  2441. OScore.setText(String.valueOf(oCount+=1));
  2442. if (Integer.parseInt(OLR.getText()) == 5){
  2443. OLR.setText(String.valueOf(OLife = 5));
  2444. }else {
  2445. OLR.setText(String.valueOf(OLife+=1));
  2446. }
  2447. random++;
  2448. }else {
  2449. OScore.setText(String.valueOf(oCount-=1));
  2450. OLR.setText(String.valueOf(OLife-=1));
  2451. random++;
  2452. }
  2453.  
  2454. }
  2455. break;
  2456. case 4:
  2457. JPanel panel4 = new JPanel();
  2458. JLabel lbl4 = new JLabel("75(89^2 + 56^2) = ");
  2459. JTextField txt4 = new JTextField(10);
  2460. panel4.add(lbl4);
  2461. panel4.add(txt4);
  2462. int selectedOption4 = JOptionPane.showOptionDialog(null, panel4, "Question No. 4: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2463. if (selectedOption4 == 0){
  2464. if (Integer.parseInt(txt4.getText()) == 829275){
  2465. OScore.setText(String.valueOf(oCount+=1));
  2466. if (Integer.parseInt(OLR.getText()) == 5){
  2467. OLR.setText(String.valueOf(OLife = 5));
  2468. }else {
  2469. OLR.setText(String.valueOf(OLife+=1));
  2470. }
  2471. random++;
  2472. }else {
  2473. OScore.setText(String.valueOf(oCount-=1));
  2474. OLR.setText(String.valueOf(OLife-=1));
  2475. random++;
  2476. }
  2477. }
  2478.  
  2479. break;
  2480. case 5:
  2481. JPanel panel5 = new JPanel();
  2482. JLabel lbl5 = new JLabel("3^4 / 68 / 59 = ");
  2483. JTextField txt5 = new JTextField(10);
  2484. panel5.add(lbl5);
  2485. panel5.add(txt5);
  2486. int selectedOption5 = JOptionPane.showOptionDialog(null, panel5, "Question No. 5: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2487. if (selectedOption5 == 0){
  2488. if (Double.parseDouble(txt5.getText()) == 0.02){
  2489. OScore.setText(String.valueOf(oCount+=1));
  2490. if (Integer.parseInt(OLR.getText()) == 5){
  2491. OLR.setText(String.valueOf(OLife = 5));
  2492. }else {
  2493. OLR.setText(String.valueOf(OLife+=1));
  2494. }
  2495. random++;
  2496. }else {
  2497. OScore.setText(String.valueOf(oCount-=1));
  2498. OLR.setText(String.valueOf(OLife-=1));
  2499. random++;
  2500. }
  2501. }
  2502. break;
  2503. case 6:
  2504. JPanel panel6 = new JPanel();
  2505. JLabel lbl6 = new JLabel("cos(56) + 64 = ");
  2506. JTextField txt6 = new JTextField(10);
  2507. panel6.add(lbl6);
  2508. panel6.add(txt6);
  2509. int selectedOption6 = JOptionPane.showOptionDialog(null, panel6, "Question No. 6: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2510. if (selectedOption6 == 0){
  2511. if (Double.parseDouble(txt6.getText()) == 64.55){
  2512. OScore.setText(String.valueOf(oCount+=1));
  2513. if (Integer.parseInt(OLR.getText()) == 5){
  2514. OLR.setText(String.valueOf(OLife = 5));
  2515. }else {
  2516. OLR.setText(String.valueOf(OLife+=1));
  2517. }
  2518. random++;
  2519. }else {
  2520. OScore.setText(String.valueOf(oCount-=1));
  2521. OLR.setText(String.valueOf(OLife-=1));
  2522. random++;
  2523. }
  2524. }
  2525.  
  2526. break;
  2527. case 7:
  2528. JPanel panel7 = new JPanel();
  2529. JLabel lbl7 = new JLabel("sin(89)^2 = ");
  2530. JTextField txt7 = new JTextField(10);
  2531. panel7.add(lbl7);
  2532. panel7.add(txt7);
  2533. int selectedOption7 = JOptionPane.showOptionDialog(null, panel7, "Question No. 7: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2534. if (selectedOption7 == 0){
  2535. if (Double.parseDouble(txt7.getText()) == 0.99){
  2536. OScore.setText(String.valueOf(oCount+=1));
  2537. if (Integer.parseInt(OLR.getText()) == 5){
  2538. OLR.setText(String.valueOf(OLife = 5));
  2539. }else {
  2540. OLR.setText(String.valueOf(OLife+=1));
  2541. }
  2542. random++;
  2543. }else {
  2544. OScore.setText(String.valueOf(oCount-=1));
  2545. OLR.setText(String.valueOf(OLife-=1));
  2546. random++;
  2547. }
  2548. }
  2549.  
  2550. break;
  2551. case 8:
  2552. JPanel panel8 = new JPanel();
  2553. JLabel lbl8 = new JLabel("tan(89) + sin(89) = ");
  2554. JTextField txt8 = new JTextField(10);
  2555. panel8.add(lbl8);
  2556. panel8.add(txt8);
  2557. int selectedOption8 = JOptionPane.showOptionDialog(null, panel8, "Question No. 8: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2558. if (selectedOption8 == 0){
  2559. if (Double.parseDouble(txt8.getText()) == 58.28){
  2560. OScore.setText(String.valueOf(oCount+=1));
  2561. if (Integer.parseInt(OLR.getText()) == 5){
  2562. OLR.setText(String.valueOf(OLife = 5));
  2563. }else {
  2564. OLR.setText(String.valueOf(OLife+=1));
  2565. }
  2566. random++;
  2567. }else {
  2568. OScore.setText(String.valueOf(oCount-=1));
  2569. OLR.setText(String.valueOf(OLife-=1));
  2570. random++;
  2571. }
  2572. }
  2573. break;
  2574. case 9:
  2575. JPanel panel9 = new JPanel();
  2576. JLabel lbl9 = new JLabel("8 square root(68)^2 + 5 =");
  2577. JTextField txt9 = new JTextField(10);
  2578. panel9.add(lbl9);
  2579. panel9.add(txt9);
  2580. int selectedOption9 = JOptionPane.showOptionDialog(null, panel9, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2581. if (selectedOption9 == 0){
  2582. if (Double.parseDouble(txt9.getText()) == 243.28){
  2583. OScore.setText(String.valueOf(oCount+=1));
  2584. if (Integer.parseInt(OLR.getText()) == 5){
  2585. OLR.setText(String.valueOf(OLife = 5));
  2586. }else {
  2587. OLR.setText(String.valueOf(OLife+=1));
  2588. }
  2589. random++;
  2590. }else {
  2591. OScore.setText(String.valueOf(oCount-=1));
  2592. OLR.setText(String.valueOf(OLife-=1));
  2593. random++;
  2594. }
  2595. }
  2596. break;
  2597. case 10:
  2598. JPanel panel10 = new JPanel();
  2599. JLabel lbl10 = new JLabel("sin(89) + 6 square root(5)^2 = ");
  2600. JTextField txt10 = new JTextField(10);
  2601. panel10.add(lbl10);
  2602. panel10.add(txt10);
  2603. int selectedOption10 = JOptionPane.showOptionDialog(null, panel10, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2604. if (selectedOption10 == 0){
  2605. if (Double.parseDouble(txt10.getText()) == 30.99){
  2606. OScore.setText(String.valueOf(oCount+=1));
  2607. if (Integer.parseInt(OLR.getText()) == 5){
  2608. OLR.setText(String.valueOf(OLife = 5));
  2609. }else {
  2610. OLR.setText(String.valueOf(OLife+=1));
  2611. }
  2612. random++;
  2613. }else {
  2614. OScore.setText(String.valueOf(oCount-=1));
  2615. OLR.setText(String.valueOf(OLife-=1));
  2616. random++;
  2617. }
  2618. }
  2619. break;
  2620. case 11:
  2621. JPanel panel11 = new JPanel();
  2622. JLabel lbl11 = new JLabel("56^2 + 56^2 / 69 = ");
  2623. JTextField txt11 = new JTextField(10);
  2624. panel11.add(lbl11);
  2625. panel11.add(txt11);
  2626. int selectedOption11 = JOptionPane.showOptionDialog(null, panel11, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2627. if (selectedOption11 == 0){
  2628. if (Double.parseDouble(txt11.getText()) == 3181.44){
  2629. OScore.setText(String.valueOf(oCount+=1));
  2630. if (Integer.parseInt(OLR.getText()) == 5){
  2631. OLR.setText(String.valueOf(OLife = 5));
  2632. }else {
  2633. OLR.setText(String.valueOf(OLife+=1));
  2634. }
  2635. random++;
  2636. }else {
  2637. OScore.setText(String.valueOf(oCount-=1));
  2638. OLR.setText(String.valueOf(OLife-=1));
  2639. random++;
  2640. }
  2641. }
  2642. break;
  2643. case 12:
  2644. JPanel panel12 = new JPanel();
  2645. JLabel lbl12 = new JLabel("89 + tan(65) = ");
  2646. JTextField txt12 = new JTextField(10);
  2647. panel12.add(lbl12);
  2648. panel12.add(txt12);
  2649. int selectedOption12 = JOptionPane.showOptionDialog(null, panel12, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2650. if (selectedOption12 == 0){
  2651. if (Double.parseDouble(txt12.getText()) == 91.14){
  2652. OScore.setText(String.valueOf(oCount+=1));
  2653. if (Integer.parseInt(OLR.getText()) == 5){
  2654. OLR.setText(String.valueOf(OLife = 5));
  2655. }else {
  2656. OLR.setText(String.valueOf(OLife+=1));
  2657. }
  2658. random++;
  2659. }else {
  2660. OScore.setText(String.valueOf(oCount-=1));
  2661. OLR.setText(String.valueOf(OLife-=1));
  2662. random++;
  2663. }
  2664. }
  2665. break;
  2666. case 13:
  2667. JPanel panel13 = new JPanel();
  2668. JLabel lbl13 = new JLabel("56 + 79^2 + 69^3 = ");
  2669. JTextField txt13 = new JTextField(10);
  2670. panel13.add(lbl13);
  2671. panel13.add(txt13);
  2672. int selectedOption13 = JOptionPane.showOptionDialog(null, panel13, "Question No. 9: ", JOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);
  2673. if (selectedOption13 == 0){
  2674. if (Integer.parseInt(txt13.getText()) == 334806){
  2675. OScore.setText(String.valueOf(oCount+=1));
  2676. if (Integer.parseInt(OLR.getText()) == 5){
  2677. OLR.setText(String.valueOf(OLife = 5));
  2678. }else {
  2679. OLR.setText(String.valueOf(OLife+=1));
  2680. }
  2681. random++;
  2682. }else {
  2683. OScore.setText(String.valueOf(oCount-=1));
  2684. OLR.setText(String.valueOf(OLife-=1));
  2685. random++;
  2686. }
  2687. }
  2688. break;
  2689.  
  2690. }
  2691. }
  2692.  
  2693. private static void choosePlayer(){
  2694. if (StartGame.equalsIgnoreCase("X")){
  2695. StartGame = "O";
  2696. }else {
  2697. StartGame = "X";
  2698. }
  2699. }
  2700.  
  2701. private static void winningGame(){
  2702. String b1 = t1.getText();
  2703. String b2 = t2.getText();
  2704. String b3 = t3.getText();
  2705.  
  2706. String b4 = t4.getText();
  2707. String b5 = t5.getText();
  2708. String b6 = t6.getText();
  2709.  
  2710. String b7 = t7.getText();
  2711. String b8 = t8.getText();
  2712. String b9 = t9.getText();
  2713. //HORIZONTAL
  2714.  
  2715. if (b1.equals("X") && b2.equals("X") && b3.equals("X")){
  2716. t1.setIcon(deletegrey);
  2717. t2.setIcon(deletegrey);
  2718. t3.setIcon(deletegrey);
  2719. xCount++;
  2720. gameScore();
  2721. JOptionPane.showMessageDialog(null,"PLAYER X WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  2722. t1.setText("");
  2723. t1.setIcon(null);
  2724. t2.setText("");
  2725. t2.setIcon(null);
  2726. t3.setText("");
  2727. t3.setIcon(null);
  2728. t4.setText("");
  2729. t4.setIcon(null);
  2730. t5.setText("");
  2731. t5.setIcon(null);
  2732. t6.setText("");
  2733. t6.setIcon(null);
  2734. t7.setText("");
  2735. t7.setIcon(null);
  2736. t8.setText("");
  2737. t8.setIcon(null);
  2738. t9.setText("");
  2739. t9.setIcon(null);
  2740. StartGame = "X";
  2741. for (int i = 0; i <buttonUsed.length; i ++){
  2742. buttonUsed[i] = 0;
  2743. }
  2744.  
  2745.  
  2746. }
  2747.  
  2748. if (b1.equals("O") && b2.equals("O") && b3.equals("O")){
  2749. t1.setIcon(circlegrey);
  2750. t2.setIcon(circlegrey);
  2751. t3.setIcon(circlegrey);
  2752. oCount++;
  2753. gameScore();
  2754. JOptionPane.showMessageDialog(null,"PLAYER O WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  2755. t1.setText("");
  2756. t1.setIcon(null);
  2757. t2.setText("");
  2758. t2.setIcon(null);
  2759. t3.setText("");
  2760. t3.setIcon(null);
  2761. t4.setText("");
  2762. t4.setIcon(null);
  2763. t5.setText("");
  2764. t5.setIcon(null);
  2765. t6.setText("");
  2766. t6.setIcon(null);
  2767. t7.setText("");
  2768. t7.setIcon(null);
  2769. t8.setText("");
  2770. t8.setIcon(null);
  2771. t9.setText("");
  2772. t9.setIcon(null);
  2773. StartGame = "X";
  2774. for (int i = 0; i <buttonUsed.length; i ++){
  2775. buttonUsed[i] = 0;
  2776. }
  2777.  
  2778. }
  2779.  
  2780. if (b4.equals("X") && b5.equals("X") && b6.equals("X")){
  2781.  
  2782. t4.setIcon(deletegrey);
  2783. t5.setIcon(deletegrey);
  2784. t6.setIcon(deletegrey);
  2785. xCount++;
  2786. gameScore();
  2787. JOptionPane.showMessageDialog(null,"PLAYER X WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  2788. t1.setText("");
  2789. t1.setIcon(null);
  2790. t2.setText("");
  2791. t2.setIcon(null);
  2792. t3.setText("");
  2793. t3.setIcon(null);
  2794. t4.setText("");
  2795. t4.setIcon(null);
  2796. t5.setText("");
  2797. t5.setIcon(null);
  2798. t6.setText("");
  2799. t6.setIcon(null);
  2800. t7.setText("");
  2801. t7.setIcon(null);
  2802. t8.setText("");
  2803. t8.setIcon(null);
  2804. t9.setText("");
  2805. t9.setIcon(null);
  2806. StartGame = "X";
  2807. for (int i = 0; i <buttonUsed.length; i ++){
  2808. buttonUsed[i] = 0;
  2809. }
  2810. }
  2811.  
  2812. if (b4.equals("O") && b5.equals("O") && b6.equals("O")){
  2813.  
  2814. t4.setIcon(circlegrey);
  2815. t5.setIcon(circlegrey);
  2816. t6.setIcon(circlegrey);
  2817. oCount++;
  2818. gameScore();
  2819. JOptionPane.showMessageDialog(null,"PLAYER O WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  2820. t1.setText("");
  2821. t1.setIcon(null);
  2822. t2.setText("");
  2823. t2.setIcon(null);
  2824. t3.setText("");
  2825. t3.setIcon(null);
  2826. t4.setText("");
  2827. t4.setIcon(null);
  2828. t5.setText("");
  2829. t5.setIcon(null);
  2830. t6.setText("");
  2831. t6.setIcon(null);
  2832. t7.setText("");
  2833. t7.setIcon(null);
  2834. t8.setText("");
  2835. t8.setIcon(null);
  2836. t9.setText("");
  2837. t9.setIcon(null);
  2838. StartGame = "X";
  2839. for (int i = 0; i <buttonUsed.length; i ++){
  2840. buttonUsed[i] = 0;
  2841. }
  2842. }
  2843.  
  2844. if (b7.equals("X") && b8.equals("X") && b9.equals("X")){
  2845.  
  2846. t7.setIcon(deletegrey);
  2847. t8.setIcon(deletegrey);
  2848. t9.setIcon(deletegrey);
  2849. xCount++;
  2850. gameScore();
  2851. JOptionPane.showMessageDialog(null,"PLAYER X WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  2852. t1.setText("");
  2853. t1.setIcon(null);
  2854. t2.setText("");
  2855. t2.setIcon(null);
  2856. t3.setText("");
  2857. t3.setIcon(null);
  2858. t4.setText("");
  2859. t4.setIcon(null);
  2860. t5.setText("");
  2861. t5.setIcon(null);
  2862. t6.setText("");
  2863. t6.setIcon(null);
  2864. t7.setText("");
  2865. t7.setIcon(null);
  2866. t8.setText("");
  2867. t8.setIcon(null);
  2868. t9.setText("");
  2869. t9.setIcon(null);
  2870. StartGame = "X";
  2871. for (int i = 0; i <buttonUsed.length; i ++){
  2872. buttonUsed[i] = 0;
  2873. }
  2874.  
  2875. }
  2876.  
  2877. if (b7.equals("O") && b8.equals("O") && b9.equals("O")){
  2878.  
  2879. t7.setIcon(circlegrey);
  2880. t8.setIcon(circlegrey);
  2881. t9.setIcon(circlegrey);
  2882. oCount++;
  2883. gameScore();
  2884. JOptionPane.showMessageDialog(null,"PLAYER O WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  2885. t1.setText("");
  2886. t1.setIcon(null);
  2887. t2.setText("");
  2888. t2.setIcon(null);
  2889. t3.setText("");
  2890. t3.setIcon(null);
  2891. t4.setText("");
  2892. t4.setIcon(null);
  2893. t5.setText("");
  2894. t5.setIcon(null);
  2895. t6.setText("");
  2896. t6.setIcon(null);
  2897. t7.setText("");
  2898. t7.setIcon(null);
  2899. t8.setText("");
  2900. t8.setIcon(null);
  2901. t9.setText("");
  2902. t9.setIcon(null);
  2903. StartGame = "X";
  2904. for (int i = 0; i <buttonUsed.length; i ++){
  2905. buttonUsed[i] = 0;
  2906. }
  2907. }
  2908.  
  2909. if (b1.equals("X") && b5.equals("X") && b9.equals("X")){
  2910.  
  2911. t1.setIcon(deletegrey);
  2912. t5.setIcon(deletegrey);
  2913. t9.setIcon(deletegrey);
  2914. xCount++;
  2915. gameScore();
  2916. JOptionPane.showMessageDialog(null,"PLAYER X WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  2917. t1.setText("");
  2918. t1.setIcon(null);
  2919. t2.setText("");
  2920. t2.setIcon(null);
  2921. t3.setText("");
  2922. t3.setIcon(null);
  2923. t4.setText("");
  2924. t4.setIcon(null);
  2925. t5.setText("");
  2926. t5.setIcon(null);
  2927. t6.setText("");
  2928. t6.setIcon(null);
  2929. t7.setText("");
  2930. t7.setIcon(null);
  2931. t8.setText("");
  2932. t8.setIcon(null);
  2933. t9.setText("");
  2934. t9.setIcon(null);
  2935. StartGame = "X";
  2936. for (int i = 0; i <buttonUsed.length; i ++){
  2937. buttonUsed[i] = 0;
  2938. }
  2939. }
  2940.  
  2941. //SLANT
  2942.  
  2943. if (b1.equals("O") && b5.equals("O") && b9.equals("O")){
  2944.  
  2945. t1.setIcon(circlegrey);
  2946. t5.setIcon(circlegrey);
  2947. t9.setIcon(circlegrey);
  2948. oCount++;
  2949. gameScore();
  2950. JOptionPane.showMessageDialog(null,"PLAYER O WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  2951. t1.setText("");
  2952. t1.setIcon(null);
  2953. t2.setText("");
  2954. t2.setIcon(null);
  2955. t3.setText("");
  2956. t3.setIcon(null);
  2957. t4.setText("");
  2958. t4.setIcon(null);
  2959. t5.setText("");
  2960. t5.setIcon(null);
  2961. t6.setText("");
  2962. t6.setIcon(null);
  2963. t7.setText("");
  2964. t7.setIcon(null);
  2965. t8.setText("");
  2966. t8.setIcon(null);
  2967. t9.setText("");
  2968. t9.setIcon(null);
  2969. StartGame = "X";
  2970. for (int i = 0; i <buttonUsed.length; i ++){
  2971. buttonUsed[i] = 0;
  2972. }
  2973. }
  2974.  
  2975. if (b3.equals("X") && b5.equals("X") && b7.equals("X")){
  2976.  
  2977. t3.setIcon(deletegrey);
  2978. t5.setIcon(deletegrey);
  2979. t7.setIcon(deletegrey);
  2980. xCount++;
  2981. gameScore();
  2982. JOptionPane.showMessageDialog(null,"PLAYER X WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  2983. t1.setText("");
  2984. t1.setIcon(null);
  2985. t2.setText("");
  2986. t2.setIcon(null);
  2987. t3.setText("");
  2988. t3.setIcon(null);
  2989. t4.setText("");
  2990. t4.setIcon(null);
  2991. t5.setText("");
  2992. t5.setIcon(null);
  2993. t6.setText("");
  2994. t6.setIcon(null);
  2995. t7.setText("");
  2996. t7.setIcon(null);
  2997. t8.setText("");
  2998. t8.setIcon(null);
  2999. t9.setText("");
  3000. t9.setIcon(null);
  3001. StartGame = "X";
  3002. for (int i = 0; i <buttonUsed.length; i ++){
  3003. buttonUsed[i] = 0;
  3004. }
  3005. }
  3006.  
  3007. if (b3.equals("O") && b5.equals("O") && b7.equals("O")){
  3008.  
  3009. t3.setIcon(circlegrey);
  3010. t5.setIcon(circlegrey);
  3011. t7.setIcon(circlegrey);
  3012. oCount++;
  3013. gameScore();
  3014. JOptionPane.showMessageDialog(null,"PLAYER O WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  3015. t1.setText("");
  3016. t1.setIcon(null);
  3017. t2.setText("");
  3018. t2.setIcon(null);
  3019. t3.setText("");
  3020. t3.setIcon(null);
  3021. t4.setText("");
  3022. t4.setIcon(null);
  3023. t5.setText("");
  3024. t5.setIcon(null);
  3025. t6.setText("");
  3026. t6.setIcon(null);
  3027. t7.setText("");
  3028. t7.setIcon(null);
  3029. t8.setText("");
  3030. t8.setIcon(null);
  3031. t9.setText("");
  3032. t9.setIcon(null);
  3033. StartGame = "X";
  3034. for (int i = 0; i <buttonUsed.length; i ++){
  3035. buttonUsed[i] = 0;
  3036. }
  3037. }
  3038.  
  3039. //VERTICAL
  3040.  
  3041. if (b1.equals("X") && b4.equals("X") && b7.equals("X")){
  3042.  
  3043. t1.setIcon(deletegrey);
  3044. t4.setIcon(deletegrey);
  3045. t7.setIcon(deletegrey);
  3046. xCount++;
  3047. gameScore();
  3048. JOptionPane.showMessageDialog(null,"PLAYER X WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  3049. t1.setText("");
  3050. t1.setIcon(null);
  3051. t2.setText("");
  3052. t2.setIcon(null);
  3053. t3.setText("");
  3054. t3.setIcon(null);
  3055. t4.setText("");
  3056. t4.setIcon(null);
  3057. t5.setText("");
  3058. t5.setIcon(null);
  3059. t6.setText("");
  3060. t6.setIcon(null);
  3061. t7.setText("");
  3062. t7.setIcon(null);
  3063. t8.setText("");
  3064. t8.setIcon(null);
  3065. t9.setText("");
  3066. t9.setIcon(null);
  3067. StartGame = "X";
  3068. for (int i = 0; i <buttonUsed.length; i ++){
  3069. buttonUsed[i] = 0;
  3070. }
  3071. }
  3072.  
  3073. if (b1.equals("O") && b4.equals("O") && b7.equals("O")){
  3074.  
  3075. t1.setIcon(circlegrey);
  3076. t4.setIcon(circlegrey);
  3077. t7.setIcon(circlegrey);
  3078. oCount++;
  3079. gameScore();
  3080. JOptionPane.showMessageDialog(null,"PLAYER O WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  3081. t1.setText("");
  3082. t1.setIcon(null);
  3083. t2.setText("");
  3084. t2.setIcon(null);
  3085. t3.setText("");
  3086. t3.setIcon(null);
  3087. t4.setText("");
  3088. t4.setIcon(null);
  3089. t5.setText("");
  3090. t5.setIcon(null);
  3091. t6.setText("");
  3092. t6.setIcon(null);
  3093. t7.setText("");
  3094. t7.setIcon(null);
  3095. t8.setText("");
  3096. t8.setIcon(null);
  3097. t9.setText("");
  3098. t9.setIcon(null);
  3099. StartGame = "X";
  3100. for (int i = 0; i <buttonUsed.length; i ++){
  3101. buttonUsed[i] = 0;
  3102. }
  3103. }
  3104.  
  3105. if (b2.equals("X") && b5.equals("X") && b8.equals("X")){
  3106.  
  3107. t2.setIcon(deletegrey);
  3108. t5.setIcon(deletegrey);
  3109. t8.setIcon(deletegrey);
  3110. xCount++;
  3111. gameScore();
  3112. JOptionPane.showMessageDialog(null,"PLAYER X WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  3113. t1.setText("");
  3114. t1.setIcon(null);
  3115. t2.setText("");
  3116. t2.setIcon(null);
  3117. t3.setText("");
  3118. t3.setIcon(null);
  3119. t4.setText("");
  3120. t4.setIcon(null);
  3121. t5.setText("");
  3122. t5.setIcon(null);
  3123. t6.setText("");
  3124. t6.setIcon(null);
  3125. t7.setText("");
  3126. t7.setIcon(null);
  3127. t8.setText("");
  3128. t8.setIcon(null);
  3129. t9.setText("");
  3130. t9.setIcon(null);
  3131. StartGame = "X";
  3132. for (int i = 0; i <buttonUsed.length; i ++){
  3133. buttonUsed[i] = 0;
  3134. }
  3135. }
  3136.  
  3137. if (b2.equals("O") && b5.equals("O") && b8.equals("O")){
  3138.  
  3139. t2.setIcon(circlegrey);
  3140. t5.setIcon(circlegrey);
  3141. t8.setIcon(circlegrey);
  3142. oCount++;
  3143. gameScore();
  3144. JOptionPane.showMessageDialog(null,"PLAYER O WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  3145. t1.setText("");
  3146. t1.setIcon(null);
  3147. t2.setText("");
  3148. t2.setIcon(null);
  3149. t3.setText("");
  3150. t3.setIcon(null);
  3151. t4.setText("");
  3152. t4.setIcon(null);
  3153. t5.setText("");
  3154. t5.setIcon(null);
  3155. t6.setText("");
  3156. t6.setIcon(null);
  3157. t7.setText("");
  3158. t7.setIcon(null);
  3159. t8.setText("");
  3160. t8.setIcon(null);
  3161. t9.setText("");
  3162. t9.setIcon(null);
  3163. StartGame = "X";
  3164. for (int i = 0; i <buttonUsed.length; i ++){
  3165. buttonUsed[i] = 0;
  3166. }
  3167. }
  3168.  
  3169. if (b3.equals("X") && b6.equals("X") && b9.equals("X")){
  3170.  
  3171. t3.setIcon(deletegrey);
  3172. t6.setIcon(deletegrey);
  3173. t9.setIcon(deletegrey);
  3174. xCount++;
  3175. gameScore();
  3176. JOptionPane.showMessageDialog(null,"PLAYER X WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  3177. t1.setText("");
  3178. t1.setIcon(null);
  3179. t2.setText("");
  3180. t2.setIcon(null);
  3181. t3.setText("");
  3182. t3.setIcon(null);
  3183. t4.setText("");
  3184. t4.setIcon(null);
  3185. t5.setText("");
  3186. t5.setIcon(null);
  3187. t6.setText("");
  3188. t6.setIcon(null);
  3189. t7.setText("");
  3190. t7.setIcon(null);
  3191. t8.setText("");
  3192. t8.setIcon(null);
  3193. t9.setText("");
  3194. t9.setIcon(null);
  3195. StartGame = "X";
  3196. for (int i = 0; i <buttonUsed.length; i ++){
  3197. buttonUsed[i] = 0;
  3198. }
  3199. }
  3200.  
  3201. if (b3.equals("O") && b6.equals("O") && b9.equals("O")){
  3202.  
  3203. t3.setIcon(circlegrey);
  3204. t6.setIcon(circlegrey);
  3205. t9.setIcon(circlegrey);
  3206. oCount++;
  3207. gameScore();
  3208. JOptionPane.showMessageDialog(null,"PLAYER O WIN","TIC TAC TOE WINNER!", JOptionPane.INFORMATION_MESSAGE);
  3209. t1.setText("");
  3210. t1.setIcon(null);
  3211. t2.setText("");
  3212. t2.setIcon(null);
  3213. t3.setText("");
  3214. t3.setIcon(null);
  3215. t4.setText("");
  3216. t4.setIcon(null);
  3217. t5.setText("");
  3218. t5.setIcon(null);
  3219. t6.setText("");
  3220. t6.setIcon(null);
  3221. t7.setText("");
  3222. t7.setIcon(null);
  3223. t8.setText("");
  3224. t8.setIcon(null);
  3225. t9.setText("");
  3226. t9.setIcon(null);
  3227. StartGame = "X";
  3228. for (int i = 0; i <buttonUsed.length; i ++){
  3229. buttonUsed[i] = 0;
  3230. }
  3231. }
  3232.  
  3233.  
  3234. if (buttonUsed[0] == 1 && buttonUsed[1] == 1 && buttonUsed[2] == 1 && buttonUsed[3] == 1 && buttonUsed[4] == 1 && buttonUsed[5] == 1 && buttonUsed[6] == 1 && buttonUsed[7] == 1 && buttonUsed[8] == 1 ){
  3235. t1.setText("");
  3236. t1.setIcon(null);
  3237. t2.setText("");
  3238. t2.setIcon(null);
  3239. t3.setText("");
  3240. t3.setIcon(null);
  3241. t4.setText("");
  3242. t4.setIcon(null);
  3243. t5.setText("");
  3244. t5.setIcon(null);
  3245. t6.setText("");
  3246. t6.setIcon(null);
  3247. t7.setText("");
  3248. t7.setIcon(null);
  3249. t8.setText("");
  3250. t8.setIcon(null);
  3251. t9.setText("");
  3252. t9.setIcon(null);
  3253. StartGame = "X";
  3254. drawScore++;
  3255. DLR.setText(String.valueOf(drawScore));
  3256. for (int i = 0; i <buttonUsed.length; i ++){
  3257. buttonUsed[i] = 0;
  3258. }
  3259. JOptionPane.showMessageDialog(null,"Draw Match");
  3260. }
  3261.  
  3262. questions();
  3263.  
  3264.  
  3265. }
  3266.  
  3267. private static void gameScore(){
  3268. OScore.setText(String.valueOf(oCount));
  3269. XScore.setText(String.valueOf(xCount));
  3270. }
  3271.  
  3272.  
  3273.  
  3274. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement