Advertisement
ruhul0

Untitled

Apr 22nd, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 22.29 KB | None | 0 0
  1. import javax.swing.*;
  2.  
  3. import java.awt.Color;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6. import java.io.BufferedReader;
  7. import java.io.FileNotFoundException;
  8. import java.io.FileReader;
  9. import java.io.IOException;
  10. import java.util.ArrayList;
  11. import java.util.Random;
  12.  
  13.  
  14. public class Gui {
  15.     public static ArrayList<IQ> questionList = new ArrayList<IQ>();
  16.     JFrame game = new JFrame("Quiz");
  17.     JButton back = new JButton("Back");
  18.     JFrame gameOver = new JFrame();
  19.     JFrame gameOption = new JFrame("Choose Game");
  20.     JFrame highScoreOption = new JFrame("Choose High Score");
  21.     JFrame mathGame = new JFrame("Math Game");
  22.     JFrame quizGame = new JFrame("Quiz Game");
  23.     JLabel firstNumberDigit = new JLabel();
  24.     JLabel wrong = new JLabel ("Wrong Answer");
  25.     JLabel correct = new JLabel ("Correct Answer");
  26.     JLabel secondNumberDigit = new JLabel();
  27.     JTextField ans = new JTextField();
  28.     static JButton next = new JButton("Next");
  29.     static JButton skip = new JButton("Skip");
  30.     JLabel secondNumber = new JLabel();
  31.     JLabel firstNumber = new JLabel();
  32.     Random random = new Random();
  33.     JLabel math = new JLabel();
  34.     JLabel mathChoice = new JLabel();
  35.     JLabel lifeLabel = new JLabel();
  36.     Timer t = new Timer(1000,new TimeShow());
  37.     static JButton submit = new JButton("Submit");
  38.     JLabel time = new JLabel();
  39.     JLabel loss = new JLabel(new ImageIcon("loss.jpg"));
  40.     JLabel image = new JLabel(new ImageIcon("game.png"));
  41.     JLabel bg = new JLabel(new ImageIcon("bg.jpg"));
  42.     JLabel quizGameScore = new JLabel();
  43.  
  44.  
  45.     JLabel question1 = new JLabel();
  46.  
  47.     JButton ans1 = new JButton();
  48.     JButton ans2 = new JButton();
  49.     JButton ans3 = new JButton();
  50.     JButton ans4 = new JButton();
  51.  
  52.     boolean toogle = false;
  53.     //String playerNameMath="";
  54.     //String playerNameIQ="";
  55.     int first,second;
  56.     int sum,choice,i=0;
  57.     static int ansChoice=0;
  58.     static int ansValue,mathHighScore0=0,mathHighScore=0,life=10,timeValue=60,iqHighScore=0,iqHighScore0=0;
  59.     JLabel mathScore = new JLabel();
  60.     JLabel IQ = new JLabel();
  61.     public Gui()
  62.     {
  63.         game.setSize(500,281);
  64.         game.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  65.         game.setVisible(true);
  66.         game.setLayout(null);
  67.         JButton start = new JButton("Start");
  68.         game.add(start);
  69.         //start.setBackground(Color.red);
  70.         start.setBounds(10,10,150,30);
  71.         start.setVisible(true);
  72.         JButton highScore = new JButton("High Score");
  73.         game.add(highScore);
  74.         highScore.setBounds(10,40,150,30);
  75.         highScore.setVisible(true);
  76.         start.addActionListener(new GameOption());
  77.         highScore.addActionListener(new HighScoreOption());
  78.         game.add(image);
  79.         image.setBounds(0,0,500,281);
  80.         image.setVisible(true);
  81.         gameOver.setSize(625,508);
  82.         gameOver.add(back);
  83.         back.setBounds(0,400,100,30);
  84.         back.addActionListener(new Back());
  85.         gameOver.add(time);
  86.         time.setVisible(true);
  87.         time.setBounds(0,0,150,50);
  88.         time.setForeground(Color.red);
  89.         gameOver.add(lifeLabel);
  90.         lifeLabel.setBounds(0,51,150,50);
  91.         lifeLabel.setForeground(Color.red);
  92.         gameOver.add(loss);
  93.         loss.setBounds(0,0,625,508);
  94.         loss.setVisible(true);
  95.     }
  96.     public static void main(String[] args) {
  97.  
  98.         new Gui();
  99.     }
  100.     public class TimeShow implements ActionListener{
  101.  
  102.         @Override
  103.         public void actionPerformed(ActionEvent actionEvent) {
  104.             timeValue--;
  105.             time.setText("Time Left: " + String.valueOf(timeValue) + "s");
  106.             time.setForeground(Color.green);
  107.             if(timeValue<=0)
  108.             {
  109.                 t.stop();
  110.                 time.setText("No Time left. Restart the game");
  111.                 time.setForeground(Color.red);
  112.                 next.setEnabled(false);
  113.                 skip.setEnabled(false);
  114.                 submit.setEnabled(false);
  115.                 ans.setEditable(false);
  116.                 gameOver.setVisible(true);
  117.                 mathGame.dispose();
  118.                 if(life<=0)
  119.                 {
  120.                     lifeLabel.setText("No life left. Restart the game");
  121.                     lifeLabel.setForeground(Color.red);
  122.                     next.setEnabled(false);
  123.                     skip.setEnabled(false);
  124.                     submit.setEnabled(false);
  125.                     ans.setEditable(false);
  126.                     t.stop();
  127.  
  128.                     gameOver.setVisible(true);
  129.                     mathGame.dispose();
  130.                 }
  131.             }
  132.  
  133.         }
  134.     }
  135.     public class GameOption implements ActionListener {
  136.         @Override
  137.         public void actionPerformed(ActionEvent actionEvent) {
  138.             gameOption.setSize(500,281);
  139.             gameOption.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  140.             gameOption.setVisible(true);
  141.             gameOption.setLayout(null);
  142.             JButton quiz = new JButton("IQ Quiz");
  143.             gameOption.add(quiz);
  144.             quiz.setBounds(10,10,150,30);
  145.             quiz.setVisible(true);
  146.             quiz.setEnabled(true);
  147.             JButton math = new JButton("Math Quiz");
  148.             gameOption.add(math);
  149.             math.setBounds(10,40,150,30);
  150.             math.setVisible(true);
  151.             math.addActionListener(new MathGame());
  152.             quiz.addActionListener(new QuizGame());
  153.             game.dispose();
  154.             gameOption.add(image);
  155.             image.setBounds(0,0,500,281);
  156.             image.setVisible(true);
  157.         }
  158.     }
  159.  
  160.     public class HighScoreOption implements ActionListener {
  161.         @Override
  162.         public void actionPerformed(ActionEvent actionEvent) {
  163.             highScoreOption.setSize(500,700);
  164.             highScoreOption.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  165.             highScoreOption.setVisible(true);
  166.             highScoreOption.setLayout(null);
  167.             IQ.setText("IQ Quiz High Score: " + iqHighScore);
  168.             highScoreOption.add(IQ);
  169.             IQ.setBounds(10,10,500,30);
  170.             IQ.setVisible(true);
  171.             IQ.setForeground(Color.green);
  172.             math.setText("Math Game High Score: " +  mathHighScore);
  173.             highScoreOption.add(math);
  174.             math.setBounds(10,40,500,30);
  175.             math.setForeground(Color.green);
  176.             math.setVisible(true);
  177.  
  178.  
  179.             highScoreOption.add(back);
  180.             back.setVisible(true);
  181.             back.setBounds(0,551,150,30);
  182.             back.addActionListener(new Back());
  183.             game.dispose();
  184.             highScoreOption.add(bg);
  185.             bg.setBounds(0,0,500,700);
  186.             bg.setVisible(true);
  187.         }
  188.     }
  189.  
  190.     public class MathGame implements ActionListener {
  191.         @Override
  192.         public void actionPerformed(ActionEvent actionEvent) {
  193.             t.start();
  194.             first = random.nextInt(99) + 1;
  195.             second= random.nextInt(99) + 1;
  196.             while(second>first)
  197.             {
  198.                 first = random.nextInt(99) + 1;
  199.                 second= random.nextInt(99) + 1;
  200.             }
  201.  
  202.             choice = random.nextInt(4)+1;
  203.             mathGame.setSize(500,700);
  204.             mathGame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  205.             mathGame.setVisible(true);
  206.             mathGame.setLayout(null);
  207.             firstNumber.setText("First Number");
  208.             firstNumber.setForeground(Color.white);
  209.             mathGame.add(firstNumber);
  210.             firstNumber.setVisible(true);
  211.             firstNumber.setBounds(0,0,150,30);
  212.             //firstNumberDigit = new JLabel(String.valueOf(first));
  213.             firstNumberDigit.setText(String.valueOf(first));
  214.             firstNumberDigit.setForeground(Color.white);
  215.             mathGame.add(firstNumberDigit);
  216.             firstNumberDigit.setBounds(0,51,150,30);
  217.             firstNumberDigit.setVisible(true);
  218.             secondNumber.setText("Second Number");
  219.             secondNumber.setForeground(Color.white);
  220.             mathGame.add(secondNumber);
  221.             secondNumber.setVisible(true);
  222.             secondNumber.setBounds(151,0,150,30);
  223.             //secondNumberDigit = new JLabel(String.valueOf(second));
  224.             secondNumberDigit.setText(String.valueOf(second));
  225.  
  226.             secondNumberDigit.setForeground(Color.white);
  227.             mathGame.add(secondNumberDigit);
  228.             secondNumberDigit.setVisible(true);
  229.             secondNumberDigit.setBounds(151,51,150,30);
  230.             mathGame.add(ans);
  231.             ans.setBounds(0,301,150,30);
  232.             mathGame.add(submit);
  233.             submit.setVisible(true);
  234.             submit.setBounds(0,351,100,30);
  235.             submit.addActionListener(new Ans());
  236.             mathGame.add(next);
  237.             next.setVisible(true);
  238.             next.setBounds(0,451,150,30);
  239.             next.addActionListener(this);
  240.             mathGame.add(skip);
  241.             skip.setVisible(true);
  242.             skip.setBounds(200,451,150,30);
  243.             skip.addActionListener(new Skip());
  244.             mathGame.add(mathChoice);
  245.             mathChoice.setVisible(true);
  246.             mathChoice.setBounds(0,201,100,30);
  247.             mathChoice.setForeground(Color.white);
  248.             if(choice==1)
  249.             {
  250.  
  251.                 sum=first+second;
  252.                 mathChoice.setText("Addition");
  253.             }
  254.             else if(choice==2)
  255.             {
  256.                 sum=first-second;
  257.                 mathChoice.setText("Substraction");
  258.             }
  259.             else if(choice==3)
  260.             {
  261.                 sum=first*second;
  262.                 mathChoice.setText("Multiplication");
  263.             }
  264.             else if(choice==4)
  265.             {
  266.                 sum=first/second;
  267.                 mathChoice.setText("Division");
  268.             }
  269.             next.setEnabled(false);
  270.             mathScore.setText("Score is: " + String.valueOf(mathHighScore0));
  271.             mathScore.setForeground(Color.white);
  272.             mathGame.add(mathScore);
  273.             mathScore.setVisible(true);
  274.             mathScore.setBounds(0,501,150,30);
  275.             lifeLabel.setText("Life left: " + String.valueOf(life));
  276.             lifeLabel.setForeground(Color.green);
  277.             mathGame.add(lifeLabel);
  278.             lifeLabel.setVisible(true);
  279.             lifeLabel.setBounds(200,501,150,30);
  280.             JButton back = new JButton("Back");
  281.             mathGame.add(back);
  282.             back.setVisible(true);
  283.             back.setBounds(0,551,150,30);
  284.             back.addActionListener(new Back());
  285.             mathGame.add(time);
  286.             time.setBounds(0,600,200,30);
  287.             time.setVisible(true);
  288.             if(life<=0)
  289.             {
  290.                 lifeLabel.setText("No life left. Restart the game");
  291.                 lifeLabel.setForeground(Color.red);
  292.                 next.setEnabled(false);
  293.                 skip.setEnabled(false);
  294.                 submit.setEnabled(false);
  295.                 ans.setEditable(false);
  296.                 t.stop();
  297.  
  298.                 gameOver.setVisible(true);
  299.                 mathGame.dispose();
  300.  
  301.             }
  302.             mathGame.add(bg);
  303.             bg.setVisible(true);
  304.             bg.setBounds(0,0,500,700);
  305.             gameOption.dispose();
  306.             next.setEnabled(true);
  307.             skip.setEnabled(true);
  308.             submit.setEnabled(true);
  309.  
  310.  
  311.         }
  312.     }
  313.     public class QuizGame implements ActionListener {
  314.         @Override
  315.         public void actionPerformed(ActionEvent actionEvent) {
  316.             quizGame();
  317.  
  318.  
  319.  
  320.         }
  321.     }
  322.     void quizGame()
  323.     {
  324.         quizGame = new JFrame("Quiz Game");
  325.         ans1 = new JButton();
  326.         ans2 = new JButton();
  327.         ans3 = new JButton();
  328.         ans4 = new JButton();
  329.         next = new JButton("Next");
  330.         skip = new JButton("Skip");
  331.         question1 = new JLabel();
  332.         question1 = new JLabel();
  333.         quizGame.setSize(500, 700);
  334.         quizGame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  335.         quizGame.setVisible(true);
  336.         quizGame.setLayout(null);
  337.         try {
  338.             BufferedReader br = new BufferedReader(new FileReader("question.txt"));
  339.             String question=br.readLine();
  340.             String[] questionOption;
  341.             while(question!=null)
  342.             {
  343.                 questionOption=question.split("-");
  344.                 IQ iq = new IQ(questionOption[0],questionOption[1],questionOption[2],questionOption[3],questionOption[4],questionOption[5]);
  345.                 questionList.add(iq);
  346.                 question=br.readLine();
  347.             }
  348.         } catch (FileNotFoundException e) {
  349.             e.printStackTrace();
  350.         } catch (IOException e) {
  351.             e.printStackTrace();
  352.         }
  353.  
  354.         skip.setEnabled(true);
  355.         t.start();
  356.  
  357.         if ((questionList.get(i).Question==null)) {
  358.             i=0;
  359.         }
  360.         question1.setText(questionList.get(i).Question);
  361.         question1.setForeground(Color.white);
  362.         ans1.setText(questionList.get(i).ans1);
  363.         ans2.setText(questionList.get(i).ans2);
  364.         ans3.setText(questionList.get(i).ans3);
  365.         ans4.setText(questionList.get(i).ans4);
  366.         quizGame.add(question1);
  367.         question1.setVisible(true);
  368.         question1.setBounds(0, 0, 700, 80);
  369.         quizGame.add(ans1);
  370.         ans1.setVisible(true);
  371.         ans1.setBounds(0, 81, 200, 30);
  372.         ans1.addActionListener(new AnsChoice1());
  373.         quizGame.add(ans2);
  374.         ans2.setVisible(true);
  375.         ans2.setBounds(0, 161, 200, 30);
  376.         ans2.addActionListener(new AnsChoice2());
  377.         quizGame.add(ans3);
  378.         ans3.setVisible(true);
  379.         ans3.setBounds(0, 241, 200, 30);
  380.         ans3.addActionListener(new AnsChoice3());
  381.         quizGame.add(ans4);
  382.         ans4.setVisible(true);
  383.         ans4.setBounds(0, 321, 200, 30);
  384.         ans4.addActionListener(new AnsChoice4());
  385.  
  386.  
  387.         quizGame.add(correct);
  388.         correct.setBounds(0,361,100,40);
  389.         correct.setVisible(false);
  390.  
  391.         quizGame.add(wrong);
  392.         wrong.setBounds(0,401,150,30);
  393.         wrong.setVisible(false);
  394.  
  395.         quizGame.add(next);
  396.         next.setVisible(true);
  397.         next.setBounds(0,451,150,30);
  398.         next.addActionListener(new QuizGameNext());
  399.  
  400.         quizGame.add(skip);
  401.         skip.setVisible(true);
  402.         skip.setBounds(200,451,150,30);
  403.         skip.addActionListener(new SkipQuizGame());
  404.  
  405.         quizGame.add(time);
  406.         time.setBounds(0,600,200,30);
  407.         time.setVisible(true);
  408.  
  409.         quizGame.add(lifeLabel);
  410.         lifeLabel.setVisible(true);
  411.         lifeLabel.setBounds(200,501,150,30);
  412.  
  413.         JButton back = new JButton("Back");
  414.         quizGame.add(back);
  415.         back.setVisible(true);
  416.         back.setBounds(0,551,150,30);
  417.         back.addActionListener(new Back());
  418.  
  419.         quizGame.add(quizGameScore);
  420.         quizGameScore.setText("Score is: " + String.valueOf(iqHighScore0));
  421.         quizGameScore.setForeground(Color.green);
  422.         quizGameScore.setVisible(true);
  423.         quizGameScore.setBounds(0,501,150,30);
  424.  
  425.         quizGame.add(lifeLabel);
  426.         lifeLabel.setForeground(Color.green);
  427.         lifeLabel.setBounds(200,501,150,30);
  428.         lifeLabel.setVisible(true);
  429.         lifeLabel.setText("Life left: " + String.valueOf(life));
  430.  
  431.         quizGame.add(time);
  432.         time.setBounds(0,651,150,30);
  433.         time.setVisible(true);
  434.  
  435.         next.setEnabled(true);
  436.         skip.setEnabled(true);
  437.         submit.setEnabled(true);
  438.         ans.setEditable(true);
  439.  
  440.         life();
  441.         quizGame.add(bg);
  442.         bg.setVisible(true);
  443.         bg.setBounds(0,0,500,700);
  444.     }
  445.     public class QuizGameNext implements ActionListener{
  446.  
  447.         @Override
  448.         public void actionPerformed(ActionEvent actionEvent) {
  449.             i++;
  450.             quizGame();
  451.         }
  452.     }
  453.     public class SkipQuizGame implements ActionListener{
  454.  
  455.         @Override
  456.         public void actionPerformed(ActionEvent actionEvent) {
  457.             --life;
  458.             i++;
  459.             life();
  460.             quizGame();
  461.             lifeLabel.setText("Life left: " + String.valueOf(life));
  462.             lifeLabel.setForeground(Color.green);
  463.  
  464.         }
  465.     }
  466.     public class AnsChoice1 implements ActionListener {
  467.  
  468.         @Override
  469.         public void actionPerformed(ActionEvent actionEvent) {
  470.                 ansChoice=1;
  471.                 next.setEnabled(false);
  472.             if(ansChoice==1)
  473.             {
  474.                 if(questionList.get(i).correctAnswer.equals(questionList.get(i).ans1))
  475.                 {
  476.  
  477.                     correctAnswer();
  478.  
  479.                 } else{
  480.                     wrongAnswer();
  481.                 }
  482.                 game.dispose();
  483.             }
  484.  
  485.  
  486.         }
  487.     }
  488.  
  489.     public class AnsChoice2 implements ActionListener{
  490.  
  491.         @Override
  492.         public void actionPerformed(ActionEvent actionEvent) {
  493.             ansChoice=2;
  494.             if(ansChoice==2)
  495.             {
  496.                 next.setEnabled(false);
  497.                 if(questionList.get(i).correctAnswer.equals(questionList.get(i).ans2))
  498.                 {
  499.                     correctAnswer();
  500.  
  501.  
  502.                 } else{
  503.                     wrongAnswer();
  504.                 }
  505.                 game.dispose();
  506.             }
  507.  
  508.         }
  509.     }
  510.     public class AnsChoice3 implements ActionListener{
  511.  
  512.         @Override
  513.         public void actionPerformed(ActionEvent actionEvent) {
  514.             ansChoice=3;
  515.             if(ansChoice==3)
  516.             {
  517.                 if(questionList.get(i).correctAnswer.equals(questionList.get(i).ans3))
  518.                 {
  519.                     correctAnswer();
  520.  
  521.  
  522.             } else{
  523.                     wrongAnswer();
  524.             }
  525.                 game.dispose();
  526.  
  527.             }
  528.  
  529.  
  530.  
  531.  
  532.         }
  533.     }
  534.     public class AnsChoice4 implements ActionListener{
  535.  
  536.         @Override
  537.         public void actionPerformed(ActionEvent actionEvent) {
  538.             ansChoice=4;
  539.             if(ansChoice==4)
  540.             {
  541.  
  542.                 next.setEnabled(false);
  543.                 if(questionList.get(i).correctAnswer.equals(questionList.get(i).ans4))
  544.                 {
  545.                     correctAnswer();
  546.  
  547.  
  548.                 } else{
  549.                     wrongAnswer();
  550.                 }
  551.                 game.dispose();
  552.  
  553.             }
  554.  
  555.         }
  556.     }
  557.     void wrongAnswer(){
  558.         life--;
  559.         life();
  560.         wrong.setVisible(true);
  561.         correct.setVisible(false);
  562.         skip.setEnabled(true);
  563.         next.setEnabled(false);
  564.         wrong.setForeground(Color.red);
  565.         quizGameScore.setText("Score is: " + String.valueOf(iqHighScore0));
  566.         quizGameScore.setForeground(Color.green);
  567.         lifeLabel.setText("Life left: " + String.valueOf(life));
  568.         lifeLabel.setForeground(Color.green);
  569.  
  570.     }
  571.     void correctAnswer(){
  572.         life();
  573.         iqHighScore0++;
  574.         quizGame.add(correct);
  575.         correct.setVisible(true);
  576.         correct.setBounds(0,401,150,30);
  577.         wrong.setVisible(false);
  578.         next.setEnabled(true);
  579.         correct.setForeground(Color.GREEN);
  580.         quizGameScore.setText("Score is: " + String.valueOf(iqHighScore0));
  581.         quizGameScore.setForeground(Color.green);
  582.         lifeLabel.setText("Life left: " + String.valueOf(life));
  583.         lifeLabel.setForeground(Color.green);
  584.         if(iqHighScore0>iqHighScore){
  585.             iqHighScore=iqHighScore0;
  586.         }
  587.         submit.setEnabled(false);
  588.         skip.setEnabled(false);
  589.     }
  590.     public class Skip implements ActionListener{
  591.  
  592.         @Override
  593.         public void actionPerformed(ActionEvent actionEvent) {
  594.             life--;
  595.             lifeLabel.setText("Life left: " + String.valueOf(life));
  596.             lifeLabel.setForeground(Color.green);
  597.             life();
  598.  
  599.         }
  600.     }
  601.     class Ans implements ActionListener
  602.     {
  603.         public void actionPerformed(ActionEvent actionEvent) {
  604.             {
  605.  
  606.                 next.setEnabled(false);
  607.                 ansValue = Integer.parseInt(ans.getText());
  608.                 if(ansValue==sum)
  609.                 {
  610.                     life();
  611.                     mathHighScore0++;
  612.                     mathGame.add(correct);
  613.                     correct.setVisible(true);
  614.                     correct.setBounds(0,401,150,30);
  615.                     wrong.setVisible(false);
  616.                     firstNumberDigit.setVisible(false);
  617.                     secondNumberDigit.setVisible(false);
  618.                     next.setEnabled(true);
  619.                     correct.setForeground(Color.GREEN);
  620.                     mathScore.setText("Score is: " + String.valueOf(mathHighScore0));
  621.                     lifeLabel.setText("Life left: " + String.valueOf(life));
  622.                     lifeLabel.setForeground(Color.green);
  623.                     //skip.setEnabled(false);
  624.                     if(mathHighScore0>mathHighScore){
  625.                         mathHighScore=mathHighScore0;
  626.                     }
  627.                     submit.setEnabled(false);
  628.                     skip.setEnabled(false);
  629.  
  630.  
  631.                 }
  632.                 else{
  633.                     life--;
  634.                     life();
  635.                     mathGame.add(wrong);
  636.                     wrong.setVisible(true);
  637.                     wrong.setBounds(0,401,150,30);
  638.                     correct.setVisible(false);
  639.                     //next.setEnabled(false);
  640.                     wrong.setForeground(Color.red);
  641.                     mathScore.setText("Score is: " + String.valueOf(mathHighScore0));
  642.                     lifeLabel.setText("Life left: " + String.valueOf(life));
  643.                     lifeLabel.setForeground(Color.green);
  644.                 }
  645.                 game.dispose();
  646.             }
  647.         }
  648.     }
  649.     class Back implements ActionListener{
  650.  
  651.         @Override
  652.         public void actionPerformed(ActionEvent e) {
  653.             // TODO Auto-generated method stub
  654.             new Gui();
  655.             gameOver.dispose();
  656.             gameOption.dispose();
  657.             highScoreOption.dispose();
  658.             mathGame.dispose();
  659.             quizGame.dispose();
  660.             mathHighScore0=0;
  661.             life=10;
  662.             timeValue=60;
  663.         }
  664.  
  665.     }
  666.     void life()
  667.     {
  668.         if(life<=(-1)) {
  669.             t.stop();
  670.             quizGame.dispose();
  671.             gameOver.setVisible(true);
  672.             mathGame.dispose();
  673.  
  674.         }
  675.     }
  676. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement